I am creating a Visual Basic 6 project to copy data out of an Access file and put it in a new Excel 2010 file.
I've gotten my data extracted properly from my Access file but I'm trying to format the Page Layout my new Excel 2010 file from within my Visual Basic 6 project.
Several of my Page Layout modifications have worked fine but setting the "Orientation" to 'Landscape' has not worked so far. Either I get errors at runtime or it just doesn't change the Page Layout, "Orientation" to 'Landscape'.
So far, I used the below code to change some layout settings and they work fine:
sheet.PageSetup.CenterHeader = _
"&""Times New Roman,Bold""&12My Company" & Chr(10) & "Report"
sheet.PageSetup.RightHeader = "&""Times New Roman,Bold""&12&D &T"
sheet.PageSetup.CenterFooter = "&""Times New Roman,Bold""&12Page &P of &N"
sheet.PageSetup.PrintGridlines = True
NOTE: "sheet" is 'Set sheet = book.Worksheets(1)'
If I add the below line after the 'PrintGridLines' statement shown above, it runs without error but the "Orientation" does not get changed and none of the 'Layout' changes show above get changed?:
sheet.PageSetup.Orientation = xlLandscape
Any help would be greatly appreciated.
Thanks in advance.
Curt
Figured Out:Visual Basic 6 & Excel 2010 Page Orientation
I figured out that I needed to add a "Reference" to the 'Microsoft Excel 14.0 Object Library'. I didn't have this "Reference" set and it wouldn't do the "Align" to 'Landscape' without it. Once I went to the "Project" pull-down menu, clicked on "References" and then added a check next to the 'Microsoft Excel 14.0 Object Library', it worked fine.
I no longer need help with this issue.
Post new comment