Automatic PDF Saving with a Cell Name.
Solved
Olive30129
-
Olivier30129 -
Olivier30129 -
Hello,
I am completely new to VBA, and the only macros I have used so far were created with the macro auto-assistant, which can no longer meet my needs.
I have been searching various forums for several days now for a solution to my problem... solutions that I have found repeatedly but cannot implement... is there a helpful genius willing to assist me?
So, I have a client membership contract on the tab: (CONTRACT), (defined by a print area) that I wish to save as a PDF, in a given folder, (C:\Users\welness\Documents\OLIVIER\ARCHIVES CONTRAT ADHESION\CONTRATS DU MOIS), and under the name of a cell (AB7, which is the result of several concatenated cells) that appears on this same sheet named (CONTRACT).
In short, I am looking to save all new membership contracts in a dedicated folder with a simple "click," without altering the base matrix of my membership contract that is "filled" with multiple and varied formulas, automatically naming the new PDF file after the value in cell AB7 of this same sheet named (CONTRACT).
I know the operation is possible as I have read many answers on forums, but I cannot set this up myself by copying the "codes" I found, simply because I don't even know WHERE to copy the codes, and what to change in these codes to adapt the path to my computer.
Thank you in advance for your help
Configuration: Windows / Internet Explorer 11.0
I am completely new to VBA, and the only macros I have used so far were created with the macro auto-assistant, which can no longer meet my needs.
I have been searching various forums for several days now for a solution to my problem... solutions that I have found repeatedly but cannot implement... is there a helpful genius willing to assist me?
So, I have a client membership contract on the tab: (CONTRACT), (defined by a print area) that I wish to save as a PDF, in a given folder, (C:\Users\welness\Documents\OLIVIER\ARCHIVES CONTRAT ADHESION\CONTRATS DU MOIS), and under the name of a cell (AB7, which is the result of several concatenated cells) that appears on this same sheet named (CONTRACT).
In short, I am looking to save all new membership contracts in a dedicated folder with a simple "click," without altering the base matrix of my membership contract that is "filled" with multiple and varied formulas, automatically naming the new PDF file after the value in cell AB7 of this same sheet named (CONTRACT).
I know the operation is possible as I have read many answers on forums, but I cannot set this up myself by copying the "codes" I found, simply because I don't even know WHERE to copy the codes, and what to change in these codes to adapt the path to my computer.
Thank you in advance for your help
Configuration: Windows / Internet Explorer 11.0
2 réponses
Hello,
assign this macro to a button located on the sheet to save:
To assign this macro to a button located on the sheet to save:
https://www.excel-plus.fr/vba/demvba/affecter-une-macro-a-un-bouton/
@+ Le Pivert
assign this macro to a button located on the sheet to save:
Sub savePDF() ActiveSheet.PageSetup.PrintArea = "A1:J" & Range("J" & Rows.Count).End(xlUp).Row 'cell range to save to be adapted ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "C:\Users\welness\Documents\OLIVIER\ARCHIVES CONTRAT ADHESION\CONTRATS DU MOIS\" & Range("AB7").Value & ".pdf", Quality:= _ xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ OpenAfterPublish:=False End Sub To assign this macro to a button located on the sheet to save:
https://www.excel-plus.fr/vba/demvba/affecter-une-macro-a-un-bouton/
@+ Le Pivert
However, and of course since it's my first one... I can't do it...
I have an error message on the code I "attempted" to implement...
Compilation error
Incorrect statement outside a procedure
ActiveSheet.PageSetup.PrintArea = "B1:X124" & Range("X124" & Rows.Count).End(xlUp).Row
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\welness\Documents\OLIVIER\ARCHIVES CONTRAT ADHESION\CONTRATS DU MOIS\" & Range("AB7").Value & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False