I have an excel worksheet with ~20 different pages that i would like to save individually as pdfs to specific folders. This is a process that I have to repeat often with fresh data.
My 1st idea is a macro that uses the ExportAsFixedFormat function, where i can use variables to update the location/filename each week.
I would like to use the pages themselves as an object to export but the example i followed to create a 'page' object:
Dim objPage As Page
Set objPage = ActiveWorkbook.ActiveWindow _
.Panes(1).Pages.Item(1)
Is giving me a Run-time 438 error (Object doesnt support this property or method)
Any thoughts on this?
Alternatively i could use the the VPageBreak option to create ranges for each page but im having trouble turning vpagebreak locations into ranges.
I am a relative newbie when it comes to VBA so sample code would be very helpful. Below is the test spreadsheet with my (very simplified) data structure, where the pages split before Entity 1, entity 2, etc
[TABLE="class: grid, width: 192"]
<colgroup><col span="3"></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Entity 1 [/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]THINGS[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Entity 2 [/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]THINGS [/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
My 1st idea is a macro that uses the ExportAsFixedFormat function, where i can use variables to update the location/filename each week.
I would like to use the pages themselves as an object to export but the example i followed to create a 'page' object:
Dim objPage As Page
Set objPage = ActiveWorkbook.ActiveWindow _
.Panes(1).Pages.Item(1)
Is giving me a Run-time 438 error (Object doesnt support this property or method)
Any thoughts on this?
Alternatively i could use the the VPageBreak option to create ranges for each page but im having trouble turning vpagebreak locations into ranges.
I am a relative newbie when it comes to VBA so sample code would be very helpful. Below is the test spreadsheet with my (very simplified) data structure, where the pages split before Entity 1, entity 2, etc
[TABLE="class: grid, width: 192"]
<colgroup><col span="3"></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Entity 1 [/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]THINGS[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Entity 2 [/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]THINGS [/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]data[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]