Norma Posy
asked on
Excel "page break"
My application generates a number of Excel spreadsheets.
What is the syntax for creating a page break at a specified row number?
What is the syntax for creating a page break at a specified row number?
ASKER
Like this?
Dim oXL As Object
Set oXL = CreateObject("Excel.Application")
With oXL
.Visible = True
sCurrentName = .Workbooks.Add.Name
'
' build spreadsheet
'
.Range("A:50").Value = strSeeding(iIndex)
.Row = 51
.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
End With
ASKER
sRow = Trim(CStr(iRow))
sCellNumber = sRow & ":" & sRow
.Rows(sCellNumber).Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=sCellNumber ' ActiveCell
Error: "Variable not defined"
ActiveWondow is highlighted
ASKER
Dim oXLBook As Object
Dim oXLSheet As Object
Dim oXLReport As Object
'
Set oXLReport = CreateObject("Excel.Application")
Set oXLBook = oXLReport.Workbooks.Open
Set oXLSheet = oXLBook.Worksheets(1)
With oXLReport
.Visible = True
.Workbooks.Add
'
' build spreadsheet
'
' ===== insert page break
oXLSheet.HPagebreaks.Add Before:=oXLSheet.Range("A5")
End With
Line 6: Error: "Argument not optional"
Please help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The variable Not Defined could be your sCellNumber was not identified
Looks like you are on the right track to me.
taking yours above after modifying line 6 creates a blank WB with a page break at A5
Looks like you are on the right track to me.
taking yours above after modifying line 6 creates a blank WB with a page break at A5
ASKER
Thank You!
ActiveWindow.SelectedSheet