Hi,
I hope this isn't a repeat/silly question. I'm a newbie at this. I'm trying to generate a report using FoxPro, and I want to export & format the final report to Excel from within VFP. I have already figured out some subtle changes to make to the VB so it will run from VFP (e.g. using pixels instead of the Application.InchesToPoints method, etc.). However, I can't figure out how to incorporate certain VB elements, such as the orientation property, or "Fit to X Pages Wide by Y Pages Tall," into my FoxPro code.
Here's the current code:
PROC avg_case_profile_test
oExcel = CreateObject("Excel.Application")
With oExcel
.Visible = .T.
.Workbooks.Add() && creates 3 sheets
.Sheets(1).Select
.ActiveSheet.Name = "Avg_Case_Profile"
With .ActiveSheet.PageSetup
.CenterHeader = [&I &14] + "Target Initial Analysis" + [&I &10] + CHR(10) + "Average Case Profile"
.CenterFooter = "Exhibit 1"
.RightFooter = "&D" + Chr(10) + "Page &P of &N"
.LeftMargin = "36"
.RightMargin = "36"
.TopMargin = "72"
.BottomMargin = "54"
.HeaderMargin = "36"
.FooterMargin = "36"
.CenterHorizontally = .T.
.CenterVertically = .F.
.FitToPagesWide = 1
.FitToPagesTall = 100
.Orientation = "xlLandscape"
EndWith
EndWith
oExcel=.NULL.
Release oExcel
ENDPROC
Two issues:
1) The .Orientation property line generates the following error:
"OLE IDispatch exception code 0 from Microsoft Excel: Unable to set the Orientation property of the PageSetup class."
2) The FitToPagesWide and FitToPagesTall code doesn't supercede the "Zoom" property. If you view Page Setup from the Excel report, the "Adjust to: 100% Normal Size" button is still checked, even though the pages wide by pages tall now states 1 page by 100 pages.
Any help someone could give me would be much appreciated!
Thanks,
Jessica
I hope this isn't a repeat/silly question. I'm a newbie at this. I'm trying to generate a report using FoxPro, and I want to export & format the final report to Excel from within VFP. I have already figured out some subtle changes to make to the VB so it will run from VFP (e.g. using pixels instead of the Application.InchesToPoints method, etc.). However, I can't figure out how to incorporate certain VB elements, such as the orientation property, or "Fit to X Pages Wide by Y Pages Tall," into my FoxPro code.
Here's the current code:
PROC avg_case_profile_test
oExcel = CreateObject("Excel.Application")
With oExcel
.Visible = .T.
.Workbooks.Add() && creates 3 sheets
.Sheets(1).Select
.ActiveSheet.Name = "Avg_Case_Profile"
With .ActiveSheet.PageSetup
.CenterHeader = [&I &14] + "Target Initial Analysis" + [&I &10] + CHR(10) + "Average Case Profile"
.CenterFooter = "Exhibit 1"
.RightFooter = "&D" + Chr(10) + "Page &P of &N"
.LeftMargin = "36"
.RightMargin = "36"
.TopMargin = "72"
.BottomMargin = "54"
.HeaderMargin = "36"
.FooterMargin = "36"
.CenterHorizontally = .T.
.CenterVertically = .F.
.FitToPagesWide = 1
.FitToPagesTall = 100
.Orientation = "xlLandscape"
EndWith
EndWith
oExcel=.NULL.
Release oExcel
ENDPROC
Two issues:
1) The .Orientation property line generates the following error:
"OLE IDispatch exception code 0 from Microsoft Excel: Unable to set the Orientation property of the PageSetup class."
2) The FitToPagesWide and FitToPagesTall code doesn't supercede the "Zoom" property. If you view Page Setup from the Excel report, the "Adjust to: 100% Normal Size" button is still checked, even though the pages wide by pages tall now states 1 page by 100 pages.
Any help someone could give me would be much appreciated!
Thanks,
Jessica