'______________________________________________________________________
'###################################################################
'### Connaître le chemin du Bureau et le chemin de Mes documents ###
'###################################################################
'/// API ///
Declare Function SHGetPathFromIDList& Lib "shell32.dll" ( _
ByRef pidl As Long, ByVal pszPath As String)
Declare Function SHGetSpecialFolderLocation& Lib "shell32.dll" ( _
ByVal hwnd As Long, ByVal csidl As Long, ByRef ppidl As ITEMIDLIST)
'/// Constantes ///
Public Const CSIDL_DESKTOP = &H0
Public Const CSIDL_PERSONAL = &H5
'/// Types ///
Type SHITEMID
cb As Long
abID As Byte
End Type
Type ITEMIDLIST
mkid As SHITEMID
End Type
'###################################################################
'______________________________________________________________________
'##############################################################################################
'### Pour éviter le message d'alerte Microsoft Forms des ActiveX non sûrs ###
'##############################################################################################
'### Cette application est sur le point d'initialiser des contrôles ActiveX potentiellement ###
'### dangereux. Si la source du document est de confiance, sélectionnez Oui ###
'### et le contrôle sera initialisé en utilisant vos paramètres de document. ###
'##############################################################################################
'/// API ///
Private Declare Function SendMessage& Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String)
Private Declare Function SetTimer& Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
Private Declare Function KillTimer& Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long)
Private Declare Function GetWindowText& Lib "user32" _
Alias "GetWindowTextA" _
(ByVal hwnd As Long, ByVal lpString As String, _
ByVal cch As Long)
'/// Constante ///
Private Const TITRE_MSGBOX As String = "Microsoft Forms"
'/// Globale ///
Public OnTimer&
'___________________________
Private Sub CloseMsgBox()
Dim HwndMsgBox&
HwndMsgBox& = FindWindow(vbNullString, TITRE_MSGBOX)
Dim Ch$
Dim Tampon&
Dim reponse&
Ch$ = Space(1024)
Tampon& = Len(Ch$)
reponse& = GetWindowText(HwndMsgBox&, Ch$, Tampon&)
Ch$ = Trim(Replace(Ch$, Chr$(0), ""))
If Ch$ = TITRE_MSGBOX Then
SendMessage HwndMsgBox&, &H10, 0, ByVal 0&
End If
End Sub
'___________________________
Sub RunTimer(Delai&)
If OnTimer& > 0 Then OffTimer
OnTimer& = SetTimer(0, 0, ByVal Delai&, AddressOf CloseMsgBox)
End Sub
'___________________________
Sub OffTimer(Optional dummy As Byte)
If OnTimer& > 0 Then
OnTimer& = KillTimer(0&, OnTimer&)
OnTimer& = 0
End If
End Sub
'##############################################################################################
'###################################################################
'### Connaître le chemin du Bureau et le chemin de Mes documents ###
'###################################################################
'____________________________________
Function PathSpecial(SpecialFolder As Long) As String
Dim Retour&
Dim A$
Dim IDL As ITEMIDLIST
Retour& = SHGetSpecialFolderLocation(0, SpecialFolder, IDL)
If Retour& = 0 Then
A$ = Space(512)
Retour& = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal A$)
PathSpecial = Left(A$, InStr(A$, vbNullChar) - 1)
End If
End Function