Un question de double code
bonsoir le forum
voila ma demande je bloque sur un code vba ,j'ai besoin de mettre deux codes différent sur le workbook open mais cela fonctionne pas
peut ton mettre ses deux procedures dans deux macros
macro1
macro2
dans workbook open call
macro1
call macro2
premier macro 1
Option Explicit
Dim CB() As New Classe1
Private Sub Workbook_Open()
Dim o As OLEObject, n%
For Each o In Feuil1.OLEObjects
If TypeName(o.Object) = "CommandButton" Then
ReDim Preserve CB(n)
Set CB(n).CB = o.Object
Set CB(n).lab = Feuil1.OLEObjects("Label1").Object
n = n + 1
End If
Next
End Subvoila mon deuxieme macro
Private Sub Workbook_Open()
Application.Caption = "JENNIFER "
Application.DisplayFullScreen = True
Application.WindowState = xlMaximized
ActiveWindow.WindowState = xlMaximized
Sheets("acceuil").Activate
MsgBox "BIENVENUE :" & Chr(10) & "Nous sommes le " & Format(Date, "dddd d mmmm yyyy") & _
Chr(10) & "Il est " & Int((Now - Int(Now)) * 24) & " H " & Format(((Now - Int(Now)) * 24 - Int((Now - Int(Now)) * 24)) * 60, "00") & " mn."
MsgBox ("Dernière Modification enregistrées dans ma base : " & Format(ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "DD/MM/YY"))
End Sub3
Bonjour,
Il n'y a qu'un seul évènement ouverture donc tout le code s'y rapportant doit être écrit au sein de la même macro, linéairement.
Cependant, vous pouvez très bien saisir des macros dans des modules normaux et les exécuter via wb_open
'MODULE THISWORKBOOK
Private Sub Workbook_Open()
Call StockageObjects
Call MessageOuverture
End Sub
'MODULE NORMAL
Option Explicit
Dim CB() As New Classe1
Sub StockageObjets()
Dim o As OLEObject, n%
For Each o In Feuil1.OLEObjects
If TypeName(o.Object) = "CommandButton" Then
ReDim Preserve CB(n)
Set CB(n).CB = o.Object
Set CB(n).lab = Feuil1.OLEObjects("Label1").Object
n = n + 1
End If
Next
End Sub
'MODULE NORMAL
Sub MessageOuverture()
Application.Caption = "JENNIFER "
Application.DisplayFullScreen = True
Application.WindowState = xlMaximized
ActiveWindow.WindowState = xlMaximized
Sheets("acceuil").Activate
MsgBox "BIENVENUE :" & Chr(10) & "Nous sommes le " & Format(Date, "dddd d mmmm yyyy") & _
Chr(10) & "Il est " & Int((Now - Int(Now)) * 24) & " H " & Format(((Now - Int(Now)) * 24 - Int((Now - Int(Now)) * 24)) * 60, "00") & " mn."
MsgBox ("Dernière Modification enregistrées dans ma base : " & Format(ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "DD/MM/YY"))
End SubCordialement,
bonjour merci infiniment
je regarde cela mais je pense que le probléme est bon