I have an application written in Office 97 that is being converted to Office 2003. The application exports the results of a large query to Excel for formatting.
Early in the code I set up the references
Set MyXLApp = GetObject(, "Excel.Application")
Set MyXL = GetObject(xlsBookName)
later I set a reference to the active page
Set ThisPage = MyXL.ActiveSheet
and format it for example:
ThisPage.Cells(2, 2).NumberFormat = "@"
But the code that uses PageSetup causes Excel to crash,
I get the Windows dialog about sending the error report to MS on the following statements.
Whether I use the With statement or reference it directly, PageSetup fails.
With ThisPage.PageSetup
.PrintTitleRows = "$1:$8"
.PrintTitleColumns = ""
.LeftMargin = MyXLApp.InchesToPoints(0.5)
.RightMargin = MyXLApp.InchesToPoints(0.5)
.TopMargin = MyXLApp.InchesToPoints(0.5)
.BottomMargin = MyXLApp.InchesToPoints(0.5)
.HeaderMargin = MyXLApp.InchesToPoints(0)
.FooterMargin = MyXLApp.InchesToPoints(0)
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
End With
Has anyone seen this? I thought maybe it was a faulty install, but it occurs on several machines.
Early in the code I set up the references
Set MyXLApp = GetObject(, "Excel.Application")
Set MyXL = GetObject(xlsBookName)
later I set a reference to the active page
Set ThisPage = MyXL.ActiveSheet
and format it for example:
ThisPage.Cells(2, 2).NumberFormat = "@"
But the code that uses PageSetup causes Excel to crash,
I get the Windows dialog about sending the error report to MS on the following statements.
Whether I use the With statement or reference it directly, PageSetup fails.
With ThisPage.PageSetup
.PrintTitleRows = "$1:$8"
.PrintTitleColumns = ""
.LeftMargin = MyXLApp.InchesToPoints(0.5)
.RightMargin = MyXLApp.InchesToPoints(0.5)
.TopMargin = MyXLApp.InchesToPoints(0.5)
.BottomMargin = MyXLApp.InchesToPoints(0.5)
.HeaderMargin = MyXLApp.InchesToPoints(0)
.FooterMargin = MyXLApp.InchesToPoints(0)
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
End With
Has anyone seen this? I thought maybe it was a faulty install, but it occurs on several machines.