Je ne trouve pas l'erreur (peut-être une barre oblique \ manquante)
Quelqu'un a une idée.
Merci de votre aide.
Voiçi le code activé par un bouton:
Code : Tout sélectionner
Option VBASupport 1
Function IsWorkBookOpen(Name As String) As Boolean
Dim xWb As Workbook
On Error Resume Next
Set xWb = Application.Workbooks.Item(Name)
IsWorkBookOpen = (Not xWb Is Nothing)
End Function
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
openWB = IsWorkBookOpen("Beerxcel_LO_stock_v2.ods")
If openWB Then
Set stockWB = Workbooks("Beerxcel_LO_stock_v2.ods")
Else
stockWB_file = ThisWorkbook.Path & "\Beerxcel_LO_stock_v2.ods"
Set stockWB = Workbooks.Open(Filename:=stockWB_file)
End If
Set stockWS = stockWB.Worksheets("Stock")
For Each cell In stockWS.Range("C6:C32")
cell.Value = cell.Value - Me.Cells(cell.Row, 6).Value
Next cell
If openWB Then
Else
stockWB.Save
stockWB.Close
End If
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
openWB = IsWorkBookOpen("Beerxcel_LO_stock_v2.ods")
If openWB Then
Set stockWB = Workbooks("Beerxcel_LO_stock_v2.ods")
Else
stockWB_file = ThisWorkbook.Path & "\Beerxcel_LO_stock_v2.ods"
Set stockWB = Workbooks.Open(Filename:=stockWB_file)
End If
Set stockWS = stockWB.Worksheets("Stock")
For Each cell In stockWS.Range("H6:H32")
cell.Value = cell.Value - Me.Cells(cell.Row, 14).Value
Next cell
If openWB Then
Else
stockWB.Save
stockWB.Close
End If
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
openWB = IsWorkBookOpen("Beerxcel_LO_stock_v2.ods")
If openWB Then
Set stockWB = Workbooks("Beerxcel_LO_stock_v2.ods")
Else
stockWB_file = ThisWorkbook.Path & "\Beerxcel_LO_stock_v2.ods"
Set stockWB = Workbooks.Open(Filename:=stockWB_file)
End If
Set stockWS = stockWB.Worksheets("Stock")
For Each cell In stockWS.Range("K6:K32")
cell.Value = cell.Value - Me.Cells(cell.Row, 19).Value
Next cell
If openWB Then
Else
stockWB.Save
stockWB.Close
End If
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton4_Click()
Application.ScreenUpdating = False
openWB = IsWorkBookOpen("Beerxcel_LO_stock_v2.ods")
If openWB Then
Set stockWB = Workbooks("Beerxcel_LO_stock_v2.ods")
Else
stockWB_file = ThisWorkbook.Path & "\Beerxcel_LO_stock_v2.ods"
Set stockWB = Workbooks.Open(Filename:=stockWB_file)
End If
Set stockWS = stockWB.Worksheets("Stock")
For Each cell In stockWS.Range("N6:N32")
cell.Value = cell.Value - Me.Cells(cell.Row, 24).Value
Next cell
If openWB Then
Else
stockWB.Save
stockWB.Close
End If
Application.ScreenUpdating = True
End Sub
Private Sub Ouvrir_stock_Click()
openWB = IsWorkBookOpen("Beerxcel_LO_stock_v2.ods")
If openWB Then
Windows("Beerxcel_LO_stock_v2.ods").Activate
Application.WindowState = xlMaximized
Else
Workbooks.Open Filename:=ThisWorkbook.Path & Beerxcel_LO_stock_v2.ods
End If
End Sub

