Re : transformer excel en PDF selon un bouton
Moi je suis sur 2003 ^^
Ma macro c'est :
Private Sub CommandButton1_Click()
Dim Fichier As Variant
Fichier = "W:\nomdelentreprise\TRANSACTIONS\Commandes\" & Range("B12").Value
ActiveWorkbook.SaveAs Filename:= _
Fichier
End Sub
si je veux ajouter la macro créée pour mettre en PDF, je mets ça où ? en dessous de "fichier" ?
J'ai envie de compreeeendre !
je vais regarder le lien...
Edit : alors j'ai bien vu le lien, ça m'a pas l'air mal mais je ne comprends pas 🙁 c'est trop technique pour moi !
lodam dans sa seconde intervention dans le fil de discussion a mis un excel en exemple avec un bouton qui "PdFise" la page et enregistre le fichier sur le bureau.
Je met ici son code qui se trouve dans la feuill1 sous VB :
Private Sub CommandButton1_Click()
PrintToPDF_Early
End Sub
Sub PrintToPDF_Early()
'Author : Ken Puls (Excelguru.ca | Tips and pointers for Excel and other MS Office applications)
'Macro Purpose: Print to PDF file using PDFCreator
' (Download from SourceForge.net: PDFCreator)
' Designed for early bind, set reference to PDFCreator
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String
'/// Changer le nom du fichier de sortie sur la lign cidessous: ///
sPDFName = "testPDF.pdf"
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Imprime le document en PDF
ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Attend que le document soit entré dans la file d'impression
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Attend que l'impression du document soit terminée
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing
End Sub