Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add page breaks from VB

using VB 6, and Excel 2002, (sp2),

I am trying to add page breaks to an excel workseheet
using OLE Automation from a VB program.

I have tried

XLworksheet.HPageBreaks.Add Befo=ActiveCell
XLWorksheet.HPageBreaks.Add ExcelWrkSheet.Cells(1, 1)

and various other things suggested on the newsgroups
and helper web sites.

The VB program will compile ok, but when it tires to execute
the HPageBeask.add

I get

Run time error 1004
application defined or object-defined error

'----------------------------------------------------------------------

Microsoft has this as is documentation on this

Add method as it applies to the HPageBreaks object.
Adds a horizontal page break. Returns an HPageBreak object.
expression.Add(Before)
expression Required. An expression that returns an HPageBreaks object.

Before Required Object. A Range object. The range above which the new
page break will be added.

'-----------------------------------------------------------------------


Thanks in Advance,

Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing Education



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add page breaks from VB

I get that error if I try to use the top left cell or any cell on the top
row. Using the same syntax, it works on another cell.


also
XLWorksheet.HPageBreaks.Add ExcelWrkSheet.Cells(1, 1)

xlWorksheet and ExcelWrkSheet should be the same object/worksheet I would
think.

--
Regards,
Tom Ogilvy



"Laurence Nuttall" wrote in message
...
using VB 6, and Excel 2002, (sp2),

I am trying to add page breaks to an excel workseheet
using OLE Automation from a VB program.

I have tried

XLworksheet.HPageBreaks.Add Befo=ActiveCell
XLWorksheet.HPageBreaks.Add ExcelWrkSheet.Cells(1, 1)

and various other things suggested on the newsgroups
and helper web sites.

The VB program will compile ok, but when it tires to execute
the HPageBeask.add

I get

Run time error 1004
application defined or object-defined error

'----------------------------------------------------------------------

Microsoft has this as is documentation on this

Add method as it applies to the HPageBreaks object.
Adds a horizontal page break. Returns an HPageBreak object.
expression.Add(Before)
expression Required. An expression that returns an HPageBreaks object.

Before Required Object. A Range object. The range above which the new
page break will be added.

'-----------------------------------------------------------------------


Thanks in Advance,

Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing Education





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't move my page breaks in Page Break Preview btaft Excel Discussion (Misc queries) 6 April 27th 23 11:49 AM
When automatic page breaks are moved each cell becomes a new page Queso hotmail com> Excel Discussion (Misc queries) 0 March 30th 10 03:08 AM
Vertical page breaks won't drag in Page Break Preview Caroline Excel Discussion (Misc queries) 0 July 14th 09 12:19 PM
How do I do page breaks when view menu doesnt page break preview HeatherF55 Excel Discussion (Misc queries) 0 September 21st 07 04:24 AM
Page Breaks- Printing selected rows on same page ToddEZ Excel Discussion (Misc queries) 1 July 18th 07 04:38 PM


All times are GMT +1. The time now is 09:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"