Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BTM BTM is offline
external usenet poster
 
Posts: 3
Default need help with hpagebreak

I'm trying to create horizontal page breaks programmatically in a
spreadsheet, but I can't get it to work.

The program runs without error, but it appears as though the Excel margin
settings override my hpagebreak settings.

Below is a section of code out of my program. I'm trying to create a
pagebreak every 35 lines.

hpbCnt = 0
hpbRow = 0
Excelsheet.PageSetup.PrintArea = "$A$1:$D$" & CStr(rownum)
Dim cell As String
Do While hpbCnt < rownum + 10
hpbRow = hpbRow + 35
hpbCnt = hpbCnt + 1
cell = "d" & CStr(hpbRow)
Worksheets(1).HPageBreaks(hpbCnt).Location = Worksheets(1).Range("d" &
CStr(hpbRow))
Loop

The actual program pulls data from an AutoCAD drawing and inserts it into
Excel. The data in Excel is then formatted to be printed onto label sheets. I
need the page breaks in the correct area of the spreadsheet to get the text
positioned properly on the labels.

I would appreciate any suggestions for using hpagebreak, or any other means
of correcting this problem.
--
btm
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default need help with hpagebreak

btm,

Something like this might do it.

Option Explicit
Option Private Module

Public Sub HPageBreaksAtInterval(shTarget As Worksheet, _
lInterval As Long, _
Optional lMaxPages As Long = 30)

Dim lPageCounter As Long

With shTarget
.Cells.PageBreak = xlPageBreakNone
For lPageCounter = 1 To lMaxPages
.HPageBreaks.Add .Cells((lPageCounter * lInterval) + 1, 1)
Next lPageCounter
End With
End Sub

Robin Hammond
www.enhanceddatasystems.com

"btm" wrote in message
...
I'm trying to create horizontal page breaks programmatically in a
spreadsheet, but I can't get it to work.

The program runs without error, but it appears as though the Excel margin
settings override my hpagebreak settings.

Below is a section of code out of my program. I'm trying to create a
pagebreak every 35 lines.

hpbCnt = 0
hpbRow = 0
Excelsheet.PageSetup.PrintArea = "$A$1:$D$" & CStr(rownum)
Dim cell As String
Do While hpbCnt < rownum + 10
hpbRow = hpbRow + 35
hpbCnt = hpbCnt + 1
cell = "d" & CStr(hpbRow)
Worksheets(1).HPageBreaks(hpbCnt).Location = Worksheets(1).Range("d" &
CStr(hpbRow))
Loop

The actual program pulls data from an AutoCAD drawing and inserts it into
Excel. The data in Excel is then formatted to be printed onto label
sheets. I
need the page breaks in the correct area of the spreadsheet to get the
text
positioned properly on the labels.

I would appreciate any suggestions for using hpagebreak, or any other
means
of correcting this problem.
--
btm



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default need help with hpagebreak

btm,
Did you read the advise and links in the previous thread you started
"hpagebreak and vpagebreak" ?
If so, you would see what .HPageBreaks.Count is equal to and why you should
be getting an error of "Subscript out of range".

NickHK

"btm" wrote in message
...
I'm trying to create horizontal page breaks programmatically in a
spreadsheet, but I can't get it to work.

The program runs without error, but it appears as though the Excel margin
settings override my hpagebreak settings.

Below is a section of code out of my program. I'm trying to create a
pagebreak every 35 lines.

hpbCnt = 0
hpbRow = 0
Excelsheet.PageSetup.PrintArea = "$A$1:$D$" & CStr(rownum)
Dim cell As String
Do While hpbCnt < rownum + 10
hpbRow = hpbRow + 35
hpbCnt = hpbCnt + 1
cell = "d" & CStr(hpbRow)
Worksheets(1).HPageBreaks(hpbCnt).Location = Worksheets(1).Range("d" &
CStr(hpbRow))
Loop

The actual program pulls data from an AutoCAD drawing and inserts it into
Excel. The data in Excel is then formatted to be printed onto label

sheets. I
need the page breaks in the correct area of the spreadsheet to get the

text
positioned properly on the labels.

I would appreciate any suggestions for using hpagebreak, or any other

means
of correcting this problem.
--
btm



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default need help with hpagebreak

See one more response at your previous thread.

btm wrote:

I'm trying to create horizontal page breaks programmatically in a
spreadsheet, but I can't get it to work.

The program runs without error, but it appears as though the Excel margin
settings override my hpagebreak settings.

Below is a section of code out of my program. I'm trying to create a
pagebreak every 35 lines.

hpbCnt = 0
hpbRow = 0
Excelsheet.PageSetup.PrintArea = "$A$1:$D$" & CStr(rownum)
Dim cell As String
Do While hpbCnt < rownum + 10
hpbRow = hpbRow + 35
hpbCnt = hpbCnt + 1
cell = "d" & CStr(hpbRow)
Worksheets(1).HPageBreaks(hpbCnt).Location = Worksheets(1).Range("d" &
CStr(hpbRow))
Loop

The actual program pulls data from an AutoCAD drawing and inserts it into
Excel. The data in Excel is then formatted to be printed onto label sheets. I
need the page breaks in the correct area of the spreadsheet to get the text
positioned properly on the labels.

I would appreciate any suggestions for using hpagebreak, or any other means
of correcting this problem.
--
btm


--

Dave Peterson
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
hpagebreak and vpagebreak btm Excel Programming 6 July 5th 05 01:10 PM
HPageBreak count problem unless in page break view Tim Zych[_8_] Excel Programming 3 August 5th 04 11:54 PM
Hpagebreak help needed please Lars Kofod Excel Programming 3 November 28th 03 03:14 PM
HPageBreak dosen't f...... work Lars Kofod Excel Programming 0 November 27th 03 03:23 PM
HPageBreak billQ Excel Programming 1 July 24th 03 02:18 AM


All times are GMT +1. The time now is 12:38 PM.

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"