Sub Macro1()
'
' Macro1 Macro
'
'
ChDir "D:\savePDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"D:\factures\Copie de Copie de FACTURE.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
End Sub
Sub nouvelleFacture()
Dim nom, chemin As Variant
Dim plage As Range
With Sheets("facture")
Sheets("facture").Copy
nom = Sheets("facture").Range("B17").Value & " - " & Sheets("facture").Range("E2").Value & ".Pdf"
Select Case (Range("D8"))
Case Is = "FACTURE": chemin = "D:\savePDF" & "\Facture\"
Case Else: chemin = "D:\savePDF" & "\Devis\"
End Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
chemin & nom, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
MsgBox "Votre sauvegarde porte la référence : " & " " & nom
' .Range("J5:J10").Value = ""
End With
'Sauvegarde les modifications
ActiveWorkbook.Save
ActiveWindow.Close
End Sub
Microsoft Excel 2007 introduit un nouveau format de fichier appelé OpenXML (XML ouvert Office).
L'extension proposée par défaut lors de l'enregistrement d'un classeur est le type .xlsx.
Les autres extensions XML sont:
* Classeur autorisant les macros (.xlsm)
* Modèle par défaut (.xltx)
* Modèle autorisant les macros (.xltm)
* Macro complémentaire (.xlam)
* Le dernier format .xlsb, est une version binaire non XML.
La lettre x en fin d'extension signifie que le fichier ne contient aucune macro. La lettre m signifie que le fichier contient des macros. Si vous enregistrez et fermez votre classeur au format .xlsx alors qu'il contenait des macros, celles ci seront perdues.
Sub nouvelleFacture()
Dim nom, chemin As Variant
Dim plage As Range
With frmFacture
.Copy
nom = .Range("B17").Value & " - " & .Range("E2").Value & ".Pdf"
Select Case (.Range("D8"))
Case Is = "FACTURE": chemin = "D:\savePDF" & "\Facture\"
Case Else: chemin = "D:\savePDF" & "\Devis\"
End Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
chemin & nom, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
MsgBox "Votre sauvegarde porte la référence : " & " " & nom
.Range("A19:E33,E2:E4,E5,G5,G12,D19:D33,A41").Value = ""
End With
'Sauvegarde les modifications
ActiveWorkbook.Save
ActiveWindow.Close
Call Ajouternum
End Sub
Sub Ajouternum()
'Incrémentation N° Facture
Dim c As Long
Application.ScreenUpdating = False
With frmFacture
c = .Range("L5").Value
'.Range("L5").Value = c + 1
If .Range("D8").Value = "FACTURE" Then
.Range("L5") = c + 1
ElseIf .Range("D8").Value = "DEVIS" Then
.Range("L6") = c + 1
End If
End With
End Sub
Sub Tst_2007()
Dim sNomFichierPDF As String
Dim i As Long, Cpt As Long
Dim Ar() As String
sNomFichierPDF = ThisWorkbook.Path & "\" & "Tableau2007.pdf"
Cpt = 0
For i = 1 To ThisWorkbook.Sheets.Count
If Left(Sheets(i).Name, 2) = "RF" Or Left(Sheets(i).Name, 2) = "RC" Then
ReDim Preserve Ar(Cpt)
Ar(Cpt) = Sheets(i).Name
Cpt = Cpt + 1
End If
Next i
If Cpt = 0 Then Exit Sub
Application.ScreenUpdating = False
Sheets(Ar).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sNomFichierPDF _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Sheets("Feuil1").Select
Application.ScreenUpdating = True
End Sub
sNomFichierPDF = ThisWorkbook.Path & "\" & "Tableau2007.pdf
nom = .Range("B17").Value & " - " & .Range("E2").Value & ".Pdf"
nom = .Range("B17") & " - " & .Range("E2") .Pdf
nom = .Range("B17").Value & " - " & .Range("E2").Value & ".Xlsm"
Application.DisplayAlerts = False et true