Re : fichier en variable avec workbook open
lorsque je clique sur le bouton rien ne se déclenche :
Private Sub CommandButton2_Click()
Dim f As Long, V1 As String, V3 As String, colonnspv As Long, chemin As String, NomFichier$
NomFichier = "12-dec.xls"
If NomFichier Like Month(MonthView1.Value) & "-*" Then
Application.Visible = False
chemin = "\\reseau\fichiermois\"
Workbooks.Open (chemin & NomFichier)
Label31.Caption = Day(MonthView1) * 4 + 3
colonnspv = Day(MonthView1) * 4 + 3
Label30.Caption = Cells(13, colonnspv + 4).Text
Sheets(1).Activate
With Sheets(1)
For f = 4 To 58
If .Cells(f, colonnspv + 1) = "SO" Or .Cells(f, colonnspv + 1) = "HDJ" Or .Cells(f, colonnspv + 1) = "HD" Then
V1 = V1 & Cells(f, 3) & "." & Cells(f, 4) & Chr(10)
Label27.Caption = V1
End If
If .Cells(f, colonnspv + 3) = "HDN" Or .Cells(f, colonnspv + 3) = "SON" Or .Cells(f, colonnspv + 3) = "HD" Then
V3 = V3 & Cells(f, 3) & "." & Cells(f, 4) & Chr(10)
Label28.Caption = V3
End If
If .Cells(f, colonnspv + 4) = "HDN" Or .Cells(f, colonnspv + 4) = "SON" Or .Cells(f, colonnspv + 3) = "HD" Then
V4 = V4 & Cells(f, 3) & "." & Cells(f, 4) & Chr(10)
Label29.Caption = V4
End If
Next
End With
ActiveWorkbook.Close SaveChanges:=False
Application.Visible = True
End If
End Sub