georgesdelta
XLDnaute Nouveau
l'idée de la macro et si L1 = 2 alors c une facture a enregistrer dans le dossier BILLS
si L1 = 1 alors c un devis a enregistrer dans le dossier BILLS OLD
Sauf que le fichier s'enregistrer dans le dernier dossier utiliser pour une sauvegarde, donc la macro ne fonctionne pas
j'ai lu sur internet que ChDir ne fonctionne pas sous mac, confirmer vous ?
En vous remerciant d'avance.
Sub GENERERFACTURE()
Dim ESSAI As String
Dim NomFichier As String
Dim C As String
Dim facture As String
Dim commande As String
Dim jour As String
ESSAI = "MACINTOSH HD:Users:stuartesktop:BILLS"
commande = Range("e3").Value
facture = Range("f9").Value
jour = Day(Date) & "-" & Month(Date) & "-" & Year(Date)
NomFichier = facture & " " & commande & " " & jour
C = ESSAI & ":" & NomFichier
If Range("L1") = 2 Then
'Copie de la facture et enregistrement
ActiveSheet.Unprotect
ActiveSheet.Buttons.Add(591.75, 113.25, 150, 78.75).Select
ActiveSheet.Buttons.Add(844.5, 83.25, 170.25, 99).Select
Sheets("Facture").Copy Before:=Sheets(1)
ActiveWindow.SmallScroll Down:=21
Range("J1:W53").Select
Range("W53").Activate
ActiveSheet.Unprotect
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=-57
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Sheets("Facture").Select
Range("E3:G7").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("E3:G3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B17:E17").Select
Range("G1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I5:K39").Select
Selection.ClearContents
Selection.Delete Shift:=xlToLeft
Range("G1").Select
Sheets("Facture").Select
Range("D9:E10").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("D9:E10").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("G1").Select
If Range("L1") = 2 Then
ChDir ESSAI
End If
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=NomFichier, FileFormat:=57
ActiveWorkbook.Close
MsgBox "La facture a bien ŽtŽ enregistrŽe sous le nom : " & vbCrLf & C
End If
'Copie du devis et enregistrement
Dim DEVIS As String
Dim CHEMDEVIS As String
Dim ESSAI2 As String
Dim D As String
Dim E As String
D = Range("E3").Value
E = Range("F9").Value
DEVIS = E & " " & D
ESSAI2 = "MACINTOSH HD:Users:stuartesktop:BILLS OLD"
CHEMDEVIS = ESSAI2 & ":" & DEVIS
If Range("L1") = 1 Then
ActiveSheet.Unprotect
ActiveSheet.Buttons.Add(591.75, 113.25, 150, 78.75).Select
ActiveSheet.Buttons.Add(844.5, 83.25, 170.25, 99).Select
Sheets("Facture").Copy Before:=Sheets(1)
ActiveWindow.SmallScroll Down:=21
Range("J1:W53").Select
Range("W53").Activate
ActiveSheet.Unprotect
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=-57
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Sheets("Facture").Select
Range("E3:G7").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("E3:G3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B17:E17").Select
Range("G1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I5:K39").Select
Selection.ClearContents
Selection.Delete Shift:=xlToLeft
Range("G1").Select
Sheets("Facture").Select
Range("D9:E10").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("D9:E10").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("G1").Select
If Range("L1") = 1 Then
ChDir ESSAI2
End If
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=DEVIS, FileFormat:=57
ActiveWorkbook.Close
MsgBox "Le DEVIS a bien ŽtŽ enregistrŽe sous le nom : " & vbCrLf & DEVIS
End If
Sheets("Facture (2)").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Facture").Select
Range("i5:Q12").Select
ActiveSheet.Unprotect
Selection.Delete Shift:=xlToLeft
ActiveSheet.Protect
Range("L3").Select
End Sub
si L1 = 1 alors c un devis a enregistrer dans le dossier BILLS OLD
Sauf que le fichier s'enregistrer dans le dernier dossier utiliser pour une sauvegarde, donc la macro ne fonctionne pas
j'ai lu sur internet que ChDir ne fonctionne pas sous mac, confirmer vous ?
En vous remerciant d'avance.
Sub GENERERFACTURE()
Dim ESSAI As String
Dim NomFichier As String
Dim C As String
Dim facture As String
Dim commande As String
Dim jour As String
ESSAI = "MACINTOSH HD:Users:stuartesktop:BILLS"
commande = Range("e3").Value
facture = Range("f9").Value
jour = Day(Date) & "-" & Month(Date) & "-" & Year(Date)
NomFichier = facture & " " & commande & " " & jour
C = ESSAI & ":" & NomFichier
If Range("L1") = 2 Then
'Copie de la facture et enregistrement
ActiveSheet.Unprotect
ActiveSheet.Buttons.Add(591.75, 113.25, 150, 78.75).Select
ActiveSheet.Buttons.Add(844.5, 83.25, 170.25, 99).Select
Sheets("Facture").Copy Before:=Sheets(1)
ActiveWindow.SmallScroll Down:=21
Range("J1:W53").Select
Range("W53").Activate
ActiveSheet.Unprotect
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=-57
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Sheets("Facture").Select
Range("E3:G7").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("E3:G3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B17:E17").Select
Range("G1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I5:K39").Select
Selection.ClearContents
Selection.Delete Shift:=xlToLeft
Range("G1").Select
Sheets("Facture").Select
Range("D9:E10").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("D9:E10").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("G1").Select
If Range("L1") = 2 Then
ChDir ESSAI
End If
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=NomFichier, FileFormat:=57
ActiveWorkbook.Close
MsgBox "La facture a bien ŽtŽ enregistrŽe sous le nom : " & vbCrLf & C
End If
'Copie du devis et enregistrement
Dim DEVIS As String
Dim CHEMDEVIS As String
Dim ESSAI2 As String
Dim D As String
Dim E As String
D = Range("E3").Value
E = Range("F9").Value
DEVIS = E & " " & D
ESSAI2 = "MACINTOSH HD:Users:stuartesktop:BILLS OLD"
CHEMDEVIS = ESSAI2 & ":" & DEVIS
If Range("L1") = 1 Then
ActiveSheet.Unprotect
ActiveSheet.Buttons.Add(591.75, 113.25, 150, 78.75).Select
ActiveSheet.Buttons.Add(844.5, 83.25, 170.25, 99).Select
Sheets("Facture").Copy Before:=Sheets(1)
ActiveWindow.SmallScroll Down:=21
Range("J1:W53").Select
Range("W53").Activate
ActiveSheet.Unprotect
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=-57
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Sheets("Facture").Select
Range("E3:G7").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("E3:G3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B17:E17").Select
Range("G1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I5:K39").Select
Selection.ClearContents
Selection.Delete Shift:=xlToLeft
Range("G1").Select
Sheets("Facture").Select
Range("D9:E10").Select
Selection.Copy
Sheets("Facture (2)").Select
Range("D9:E10").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("G1").Select
If Range("L1") = 1 Then
ChDir ESSAI2
End If
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=DEVIS, FileFormat:=57
ActiveWorkbook.Close
MsgBox "Le DEVIS a bien ŽtŽ enregistrŽe sous le nom : " & vbCrLf & DEVIS
End If
Sheets("Facture (2)").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Facture").Select
Range("i5:Q12").Select
ActiveSheet.Unprotect
Selection.Delete Shift:=xlToLeft
ActiveSheet.Protect
Range("L3").Select
End Sub