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
| Private Declare Function SetWindowPos Lib "user32" (ByVal Hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Sub Test_Open_Outlook_PatrickToulon()
Dim Chemin As String
Chemin = "C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.exe"
Dim Appli As Object
Dim session_Outlook As New Outlook.Application
Dim Ole_appli As Object
Dim typouv As Byte
typouv = 1
On Error Resume Next
Set Appli = GetObject(, "Outlook.Application")
Call first_in_plan
If Appli Is Nothing Then
'Ouvre Outlook
session_Outlook = Shell(Chemin, typouv)
Else
'Fermeture de l'application Outlook si ouverte et réouverture d'une nouvelle
Set Ole_appli = CreateObject("Outlook.Application")
Ole_appli.Quit
session_Outlook = Shell(Chemin, typouv)
End If
Set Ole_appli = Nothing
Set Appli = Nothing
Call No_first_in_plan
End Sub
Sub first_in_plan()
Dim Ole_appli, posioton, L, T, W, H
Set Ole_appli = Application
T = Ole_appli.Top: L = Ole_appli.Left: W = Ole_appli.Width: H = Ole_appli.Height
position = SetWindowPos(Ole_appli.Hwnd, -1, 0, 0, 0, 0, 0)
Ole_appli.Top = T: Ole_appli.Left = L: Ole_appli.Width = W: Ole_appli.Height = H
End Sub
Sub No_first_in_plan()
Dim Ole_appli, posioton, L, T, W, H
Set Ole_appli = Application
T = Ole_appli.Top: L = Ole_appli.Left: W = Ole_appli.Width: H = Ole_appli.Height
position = SetWindowPos(Ole_appli.Hwnd, -2, 0, 0, 0, 0, 0)
Ole_appli.Top = T: Ole_appli.Left = L: Ole_appli.Width = W: Ole_appli.Height = H
End Sub |
Partager