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?
NormaPosyPhysicistAsked:
Who is Participating?
 
Brook BraswellApplication Development ManagerCommented:
The Argument Not Optional is because you do not have a book...
Modify Line 6

Set oXLBook = oXLReport.Workbooks.Add

0
 
Brook BraswellApplication Development ManagerCommented:
   ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
    ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
0
 
NormaPosyPhysicistAuthor Commented:
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

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
NormaPosyPhysicistAuthor Commented:
sRow = Trim(CStr(iRow))
sCellNumber = sRow & ":" & sRow
.Rows(sCellNumber).Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=sCellNumber ' ActiveCell

Open in new window


Error: "Variable not defined"
 ActiveWondow is highlighted
0
 
NormaPosyPhysicistAuthor Commented:
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

Open in new window


Line 6: Error: "Argument not optional"

Please help
0
 
Brook BraswellApplication Development ManagerCommented:
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
0
 
NormaPosyPhysicistAuthor Commented:
Thank You!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.