Create PDF from different ranges in multiple Excel sheets with VBA -


i need export several excel sheets 1 pdf file. using following:

sub createpdf()      sheets("reportpage1").select     range("print_area").select     sheets("reportpage2").select     range("print_area").select     sheets("reportpage3").select     range("print_area").select          thisworkbook.sheets(array("reportpage1", "reportpage2", "reportpage3")).select         selection.exportasfixedformat _             type:=xltypepdf, _             filename:="c:\temp\temp.pdf", _             quality:=xlqualitystandard, _             includedocproperties:=true, _             ignoreprintareas:=false, _             openafterpublish:=true      sheets("reportpage1").select     range("a1").select  end sub 

the problem print areas different. pdf generated using range address of print area reportpage1 pages.

i tried in excel itself, outside of vba, , when have selected, example, reportpage1!a1:e30 , reportpage2!a1:f70, when select both sheets change selected ranges reportpage1!a1:e30 , reportpage2!a1:e30.

any ideas how solve this?

any appreciated.

ok, solved it. if don't select ranges on specific pages automatically print_area range of each sheet.

sub createpdf()      thisworkbook.sheets(array("reportpage1", "reportpage2", "reportpage3")).select      sheets("reportpage1").activate      activesheet.exportasfixedformat _             type:=xltypepdf, _             filename:="c:\temp\temp.pdf", _             quality:=xlqualitystandard, _             includedocproperties:=true, _             ignoreprintareas:=false, _             openafterpublish:=true      sheets("reportpage1").select     range("a1").select  end sub 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -