Excel VBA for Mac : Save worksheet as PDF -
i working on simple macro save active sheet pdf file special name. macro have created working saving every sheets in several pdf , put name of sheet @ end of file name.
if me great, cannot see problem...
here macro :
sub printpdf() dim wkssheet worksheet dim strfile string set wkssheet = activesheet 'strfile = format(now(), "yyyymm") _ & ".pdf" strfile = "blabla" _ & "_" _ & format(now(), "yyyymm") _ & "_" _ & "name2" _ & " " _ & replace(replace(wkssheet.cells(1, 2).value, " ", ""), ".", "_") _ & ".pdf" strfile = thisworkbook.path & ":" & strfile wkssheet.saveas filename:=strfile, fileformat:=xlpdf end sub
you have discovered bug in excel mac 2011 vba!
despite using syntax of activesheet.saveas
or preferred:-
activeworkbook.saveas filename:=strfile, fileformat:=xlpdf, publishoption:=xlsheet
excel mac 2011 vba save worksheets.
if turn on macro recorder , save sheet pdf, works expected , writes out activeworkbook
version code module. re-run code generated , yields different result!
i can confirm bug not exist in excel mac 2016 , worksheet syntax no longer supported. need change workbook syntax included above.
Comments
Post a Comment