• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

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?
0
NormaPosy
Asked:
NormaPosy
  • 4
  • 3
1 Solution
 
Brook BraswellApplication Development ManagerCommented:
   ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
    ActiveWindow.SelectedSheets.VPageBreaks.Add Before:=ActiveCell
0
 
NormaPosyAuthor 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
 
NormaPosyAuthor 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
NormaPosyAuthor 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 Argument Not Optional is because you do not have a book...
Modify Line 6

Set oXLBook = oXLReport.Workbooks.Add

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
 
NormaPosyAuthor Commented:
Thank You!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now