Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Outlook > VBA Outlook
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 02/10/2007, 15h40   #1
Membre du Club
 
Inscription : septembre 2005
Messages : 95
Détails du profil
Informations forums :
Inscription : septembre 2005
Messages : 95
Points : 42
Points : 42
Par défaut MsgBox en premier plan ?

Bonjour,

J'utilise ce code que j'ai trouvé sur ce forum pour mettre automatiquement en CCI une adresse e-mail de tous mes envois Cela fonctionne très bien.. mais la popup de confirmation avant l'envoi reste derrière ma fenêtre du mail envoyé. Du coup, je dois a chaque fois cliquer sur OutLook dans la barre des tâches pour voir ma MsgBox.


Quelqu'un a une idée ?

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 
'By Oliv' 29/06/2007 pour Outlook 2003
 
Dim myRecipient As Outlook.Recipient
 
If Not Item.Class = olMail Then GoTo fin
 
Dim prompt As String
 
' ici renseigner le destinataire
 
cci = "adresse@monmail.com"
 
'commentez au choix l'option non voulue
 
'########################Option CCI############################
 
prompt = "Ajouter le cci " & cci & " à " & Item.Subject & "?"
 
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbYes Then
 
Set myRecipient = Item.Recipients.Add(cci)
 
myRecipient.Type = olBCC
 
myRecipient.Resolve
 
If myRecipient.Resolved = False Then
 
MsgBox "L'adresse Email n'est pas correcte !", vbCritical, "Erreur"
 
Cancel = True
End If
 
End If
 
'########################Option CC##############################
 
prompt = "Ajouter le cc " & cci & " à " & Item.Subject & "?"
 
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbYes Then
 
Set myRecipient = Item.Recipients.Add(cci)
 
myRecipient.Type = olCC
 
myRecipient.Resolve
 
If myRecipient.Resolved = False Then
 
MsgBox "L'adresse Email n'est pas correcte !", vbCritical, "Erreur"
 
Cancel = True
End If
 
End If
 
'#######################FIN#####################################
 
fin:
 
End Sub
oceanbigone est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/10/2007, 10h58   #2
Membre chevronné
 
Avatar de Oliv-
 
Inscription : mars 2006
Messages : 643
Détails du profil
Informations personnelles :
Âge : 41

Informations forums :
Inscription : mars 2006
Messages : 643
Points : 699
Points : 699
SAlut,
C'est parce que tu utilises word comme éditeur non ?
Oliv'
Oliv- est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/10/2007, 15h00   #3
Membre du Club
 
Inscription : septembre 2005
Messages : 95
Détails du profil
Informations forums :
Inscription : septembre 2005
Messages : 95
Points : 42
Points : 42
Merci, c'est effectivement de la que vient le problème.

Je viens d'enlever WORD comme editeur de mes mails. Mais, est-ce normal ?
oceanbigone est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/10/2007, 15h38   #4
Membre chevronné
 
Avatar de Oliv-
 
Inscription : mars 2006
Messages : 643
Détails du profil
Informations personnelles :
Âge : 41

Informations forums :
Inscription : mars 2006
Messages : 643
Points : 699
Points : 699
Salut,
Normal oui l'envoi est fait par outlook alors la msgbox se met sur outlook, mais comme la fenetre active c'est word tu vois pas le message.

Si tu veux vraiment utiliser word comme éditeur (ce qui est plutot déconseillé par rapport au html qu'il créé) tu peux demander à activer outlook .


ActiveOutlook à inclure dans ton code pour afficher outlook et ActiveMailWord si tu dois revenir sur ton mail pour une anulation par exemple.

Ok ?



Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'====================dans un module standard
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassname As String, ByVal lpWindowName As String) As Long
Declare Function SetForegroundWindow Lib "user32" _
    (ByVal hwnd As Long) As Long
Declare Function ShowWindow Lib "user32" _
    (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
 
 
' ShowWindow() Commands
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_NORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
Public Const SW_SHOWDEFAULT = 10
Public Const SW_MAX = 10
 
 
Sub ActiveOutlook()
Dim hwnd As Long
FenOutlook = Application.ActiveExplorer.CurrentFolder.Name & " - Microsoft Outlook"
'Set titi = ActiveInspector.CurrentItem
On Error Resume Next
If ActiveInspector.CurrentItem.GetInspector.EditorType = olEditorWord Then
    Cemail = FenOutlook
Else
    Cemail = ActiveInspector.CurrentItem.GetInspector.Caption
End If
'MsgBox CeMail
  'hwnd = FindWindow(vbNullString, toto)
  hwnd = FindWindow(vbNullString, Cemail)
  'Hwnd = FindWindow("rctrl_renwnd32", vbNullString)
 
  If hwnd = 0 Then Exit Sub
  SetForegroundWindow hwnd
  ShowWindow hwnd, SW_SHOWMAXIMIZED
End Sub
 
Sub ActiveMailWord()
Dim hwnd As Long
toto = "Message sans titre"
  hwnd = FindWindow(vbNullString, toto)
  ' Hwnd = FindWindow("OpusApp", vbNullString)
 
  If hwnd = 0 Then Exit Sub
  SetForegroundWindow hwnd
  ShowWindow hwnd, SW_SHOWMAXIMIZED
End Sub
Oliv- est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h32.


 
 
 
 
Partenaires

Hébergement Web