Excel PageBreaks from .Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Has anyone created HPageBreaks or VPageBreaks from their Application for Excel. I use Excel as my reporting tool for all of my Applications, and have been trying to add a new or move an existing pagebreak. But can not get code to work correctly. I have pasted some code that works up to the page break. If someone could help me or post back some code that works. Thanks

oWB = oXL.Workbooks.Add
oSheet = oWB.ActiveSheet

With oSheet
.PageSetup.PrintArea = ("a1:p30")
.DisplayPageBreaks = True
'item = .HPageBreaks.Count()
.HPageBreaks.Add("Q30")
End With
 
Bill,

I am working on a similar problem, but I think I see your problem righ
off the bat. Here is code that I think should work for you.

oWB = oXL.Workbooks.Add
oSheet = oWB.ActiveSheet

With oSheet
..PageSetup.PrintArea = ("a1:p30")
..DisplayPageBreaks = True
'item = .HPageBreaks.Count()
..HPageBreaks.Add .Range("Q30")
End With

As you can see, the Add method of the HPageBreaks Collection requires
Range object, not just an address. Hope this helps.


Bill said:
*Has anyone created HPageBreaks or VPageBreaks from their Applicatio
for Excel. I use Excel as my reporting tool for all of m
Applications, and have been trying to add a new or move an existin
pagebreak. But can not get code to work correctly. I have
pasted some code that works up to the page break. If someone coul
help me or post back some code that works. Thanks

oWB = oXL.Workbooks.Add
oSheet = oWB.ActiveSheet

With oSheet
..PageSetup.PrintArea = ("a1:p30")
..DisplayPageBreaks = True
'item = .HPageBreaks.Count()
..HPageBreaks.Add("Q30")
End With


-
billwai
 
Back
Top