VBA excel 2011 save as PDF
As posted in OZGRID (can't post the link)
Used the following:
[VBA]Sub SavePDFMacro()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Macintosh HD:Users:Mach7:Desktop:" & Range("AA1").Value, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
[/VBA]
The set print area should be saved as a PDF file onto the desktop using as file name the value found in Cell AA1.
The code is doing just that. No issue here.
I would like to adjust the paper size and the margin as to maximize the appearance.
Right now I get a pdf that is either a A4 or a 8.5 by 11.
Any suggestion to force the pdf to save as legal that is 8.5 by 13 (215.9 by 330.91 mm). Note Excel is already using this size as default, however the created PDF does not.
Thanks for your suggestions.
AppleScript to set page size
Quote:
Originally Posted by
cyrilbrd
As posted in OZGRID (can't post the link)
I would like to adjust the paper size and the margin as to maximize the appearance.
Right now I get a pdf that is either a A4 or a 8.5 by 11.
Any suggestion to force the pdf to save as legal that is 8.5 by 13 (215.9 by 330.91 mm). Note Excel is already using this size as default, however the created PDF does not.
Thanks for your suggestions.
I beat my head on the wall for a while on this and figured out some AppleScript to set page size just before printing. Excel 2011 has some bug where it won't remember page size when saving the file. This is my work around. Use the VBA macscript command with the following script.
tell application "Microsoft Excel"
activate
end tell
tell application "System Events"
delay 0.5
--keystroke "a" using command down
tell application process "Microsoft Excel"
click menu item "Page Setup..." of menu "File" of menu bar item "File" of menu bar 1
delay 0.5
keystroke "o" using command down --This clicks the Option... button
delay 0.5
click pop up button 3 of window "Page Setup" --This clicks the Paper Size: drop down. button 2 clicks the Format For: drop down
delay 0.5
keystroke "4" --Use the first couple of letters of your desired page size. for me it was 4" x 2-1/2" tag
keystroke return
delay 0.5
keystroke return
delay 0.5
keystroke return
delay 0.5
end tell
end tell