Oui, j'ai bien laissé la Macro dans ThisWorkBook.
Je pense que les différentes lignes de codes font interférences entre elles.
Voici ce que j'ai dans ThisWorkBook:
Sub Workbook_open()
Application.Visible = False
ProgIDoZ.Show vbModeless
End Sub
Et dans le Userform (nommé ProgIDoZ):
Private Declare Function FindWindowA& Lib "User32" _
(ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function EnableWindow& Lib "User32" _
(ByVal hWnd&, ByVal bEnable&)
Private Declare Function GetWindowLongA& Lib "User32" _
(ByVal hWnd&, ByVal nIndex&)
Private Declare Function SetWindowLongA& Lib "User32" _
(ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
Private Sub UserForm_Initialize()
Dim hWnd As Long
hWnd = FindWindowA(vbNullString, Me.Caption)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000
End Sub
Private Sub UserForm_Activate()
Dim hWnd As Long
hWnd = FindWindowA("XLMAIN", Application.Caption)
EnableWindow hWnd, 1
End Sub
Private Sub CommandButton4_Click()
Application.Quit
End Sub
Private Sub CommandButton1_Click()
Range("O2").Select
Selection.Copy
Range("P2").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("P2").Select
Application.CutCopyMode = False
Selection.Copy
End Sub
Private Sub CommandButton2_Click()
Range("O6").Select
ActiveCell.FormulaR1C1 = _
"=(2100-RC[-4])&VLOOKUP(RC[-3],Aire_administrative_concernée,2,FALSE)&VLOOKUP(RC[-2],Type_de_document,2,FALSE)&"",""&VLOOKUP(RC[-1],Type_de_pièce,2,FALSE)"
Range("O6").Select
Selection.Copy
Range("P6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
End Sub
Private Sub CommandButton3_Click()
Application.Visible = True
End Sub
Private Sub Form_Terminate()
Application.Quit
End Sub
Private Sub Label5_Click()
End Sub