Fin d'instruction
Bonsoir,
Je n'arrive pas à régler ce problème suite au message "Erreur de compilation" Attendu "Fin d'instruction"
dans le code ci dessous. Si quelqu'un peu m'aider ?
Merci pour votre aide.
Option Explicit
Private Declare PtrSafe Function FindWindow& Lib "user64" _
Alias "FindWindowA" _
(ByVal lpClassName$, ByVal lpWindowName$)
Private Declare PtrSafe Function ScreenToClient& Lib "user64" _
(ByVal hWnd&, ByRef lpPoint As POINTAPI)
Private Declare PtrSafe Function GetWindowRect& Lib "user64" _
(ByVal hWnd&, lpRect As RECT)
Private Declare PtrSafe Function CreateWindowEx& Lib "user64" ()
_
Alias "CreateWindowExA" _
(ByVal dwExStyle&, ByVal lpClassName$, ByVal lpWindowName$, _
ByVal dwStyle&, ByVal X&, ByVal y&, ByVal nWidth&, _
ByVal nHeight&, ByVal hWndParent&, ByVal hMenu&, _
ByVal hInstance&, ByRef lpParam As Any)
Private Declare PtrSafe Function InitCommonControlsEx& Lib "comctl64" _
(ByRef INITCOMMONCONTROLSEXData As InitCommonControlsExType)
Private Declare PtrSafe Function DestroyWindow& Lib "user64" _
(ByVal hWnd&)
Private Declare PtrSafe Function SendMessage& Lib "user64" _
Alias "SendMessageA" _
(ByVal hWnd&, ByVal wMsg&, ByVal wParam&, ByRef lParam As Any)
Private Declare PtrSafe Function SetWindowPos& Lib "user64" _
(ByVal hWnd&, ByVal hWndInsertAfter&, ByVal X&, _
ByVal y&, ByVal cx&, ByVal cy&, ByVal wFlags&)
Private Type InitCommonControlsExType
dwSize As Long
dwICC As Long
End Type
Private Type POINTAPI
X As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private mWnd&
Public ObjetSource As Object
Private Sub UserForm_Initialize()
Const WS_CHILD& = &H40000000, MONTHCAL_CLASS$ = "SysMonthCal32", _
MCM_FIRST& = &H1000&, MCM_GETMINREQRECT& = (MCM_FIRST + 9&), _
SWP_SHOWWINDOW& = &H40&, MCS_NOTODAY& = &H10&, _
MCS_NOTODAYCIRCLE& = &H8&, ICC_DATE_CLASSES& = &H100&
Dim CalRect As RECT, LeTop&, LeLeft&, hWnd&, Marge&, CvtPtPixel!, _
IniCtrl As InitCommonControlsExType, PtCal As POINTAPI
LeTop = 5&
Marge = 5&
CvtPtPixel = 3 / 4 - 0.31
hWnd = FindWindow(vbNullString, Me.Caption)
'Création du controle calendrier
With IniCtrl
.dwSize = Len(IniCtrl)
.dwICC = ICC_DATE_CLASSES
End With
InitCommonControlsEx IniCtrl
mWnd = CreateWindowEx(0&, MONTHCAL_CLASS, vbNullString, _
WS_CHILD Or MCS_NOTODAY Or MCS_NOTODAYCIRCLE _
, 0&, 0&, 0&, 0&, hWnd, 0&, 0&, 0&)
'Ajustement de la position du control calendrier
SendMessage mWnd, MCM_GETMINREQRECT, 0&, CalRect
SetWindowPos mWnd, 0, LeTop, Marge, CalRect.Right + Marge, _
CalRect.Bottom + LeTop, SWP_SHOWWINDOW
'Ajustement de la position des boutons
GetWindowRect mWnd, CalRect
With CalRect
PtCal.X = .Right
PtCal.y = .Top
End With
ScreenToClient hWnd, PtCal
LeLeft = PtCal.X * CvtPtPixel + Marge
With CommandButton1 'OK
.Left = LeLeft - 10 '= LeLeft
.Top = PtCal.y * CvtPtPixel + 111
LeTop = LeTop * 4 + .Height
End With
With CommandButton2 'Annuler
.Left = LeLeft - 80
.Top = LeTop + 71
End With
'Ajustement de la taille du UserForm
With CalRect
PtCal.X = .Top
PtCal.y = .Bottom
End With
ScreenToClient hWnd, PtCal
With Me
.Width = CommandButton1.Width + LeLeft
.Height = (PtCal.X + PtCal.y + 196) * CvtPtPixel
End With
End Sub
- Messages
- 308
- Excel
- 2016
- Inscrit
- 15/06/2017
- Emploi
- Bénéficiaire de la sécurité de la vieillesse
Bonjour bpl, bonjour le forum,
Tu as eu le malheur de faire un "ENTER" à la fin de la ligne. Remarque les () de trop et le _ rendu sur l'autre ligne.
change le bout :
Private Declare PtrSafe Function CreateWindowEx& Lib "user64" ()
_
Alias "CreateWindowExA" _
(ByVal dwExStyle&, ByVal lpClassName$, ByVal lpWindowName$, _
ByVal dwStyle&, ByVal X&, ByVal y&, ByVal nWidth&, _
ByVal nHeight&, ByVal hWndParent&, ByVal hMenu&, _
ByVal hInstance&, ByRef lpParam As Any)Pour :
Private Declare PtrSafe Function CreateWindowEx& Lib "user64" _
Alias "CreateWindowExA" _
(ByVal dwExStyle&, ByVal lpClassName$, ByVal lpWindowName$, _
ByVal dwStyle&, ByVal X&, ByVal y&, ByVal nWidth&, _
ByVal nHeight&, ByVal hWndParent&, ByVal hMenu&, _
ByVal hInstance&, ByRef lpParam As Any)Joseph
Merci retraite8,
Vraiment super ce forum et ses bienfaiteurs.
Je viens de changer le bout de code mais je rencontre un autre souci !!
Je joins le fichier pour savoir pourquoi ?
Merci encore
Merci retraite8,
J'ai trouvé mon erreur, une fausse manip sur le nom.
Ton aide m'a été précieuse.
Cordialement
- Messages
- 308
- Excel
- 2016
- Inscrit
- 15/06/2017
- Emploi
- Bénéficiaire de la sécurité de la vieillesse
Bonjour bpl, bonjour le forum,
Joseph