Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default Printing header on all but last page

I have a specific row I want to print as a header for all but the last page.
I have tried using :

Totpages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
..PrintTitleRows = "$20:$20"
ActiveSheet.PrintOut From:=1, To:=Totpages-1
..PrintTitleRows = ""
ActiveSheet.PrintOut From:=Totpages, To:=Totpages

But the problem is that it will do two passes in preview. I need to have
the entire sheet formated properly in one pass so I can convert to a PDF
document.

The other problem is that the sheet can vary in length from 2 to 10 pages so
I cannot hardwire anything.

I really need a routine that can test what rows are in each page, or
possibly search for a unique keyword within the page. If found, insert
header (.PrintTitleRows = "$20:$20") otherwise do not do insertion
(.PrintTitleRows = "").

Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Printing header on all but last page

It seems to me that you will need to do that programatically
by inserting or copying your header row(s). You might want
to copy your sheet to another sheet and do this:
Sub sub1()
Dim iHBrk%, iRow&
iHBrk = 1
iRow = 1
Do
' maybe somebody else can explain why this next statement
' is needed (at least in excel 97)
ActiveSheet.UsedRange.SpecialCells(xlLastCell).Sel ect
If iHBrk ActiveSheet.HPageBreaks.Count Then Exit Do
Rows(iRow).Insert
Cells(iRow, 1) = "Header"
iRow = ActiveSheet.HPageBreaks(iHBrk).Location
iHBrk = iHBrk + 1
Loop
End Sub

Don wrote:

I have a specific row I want to print as a header for all but the last page.
I have tried using :

Totpages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
.PrintTitleRows = "$20:$20"
ActiveSheet.PrintOut From:=1, To:=Totpages-1
.PrintTitleRows = ""
ActiveSheet.PrintOut From:=Totpages, To:=Totpages

But the problem is that it will do two passes in preview. I need to have
the entire sheet formated properly in one pass so I can convert to a PDF
document.

The other problem is that the sheet can vary in length from 2 to 10 pages so
I cannot hardwire anything.

I really need a routine that can test what rows are in each page, or
possibly search for a unique keyword within the page. If found, insert
header (.PrintTitleRows = "$20:$20") otherwise do not do insertion
(.PrintTitleRows = "").

Thanks in advance




----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
  #3   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default Printing header on all but last page

Thanks Dave,

Only thing I found was that I needed to modify one line of your code as I
got a type mismatch error:
iRow = ActiveSheet.HPageBreaks(iHBrk).Location.Row
I am running Acces 2000

Since I did not want the file to have those inserts in my saved file I just
created an array of row numbers inserted and after preview/print they are
removed. Seems to work fine, awkward but does the trick.
You may be right in doing a copy to another sheet and print/preview that one.
Then I can re-use that sheet as workspace and the original sheet is untouched.
My next little project.

Don

"Dave D-C" wrote:

It seems to me that you will need to do that programatically
by inserting or copying your header row(s). You might want
to copy your sheet to another sheet and do this:
Sub sub1()
Dim iHBrk%, iRow&
iHBrk = 1
iRow = 1
Do
' maybe somebody else can explain why this next statement
' is needed (at least in excel 97)
ActiveSheet.UsedRange.SpecialCells(xlLastCell).Sel ect
If iHBrk ActiveSheet.HPageBreaks.Count Then Exit Do
Rows(iRow).Insert
Cells(iRow, 1) = "Header"
iRow = ActiveSheet.HPageBreaks(iHBrk).Location
iHBrk = iHBrk + 1
Loop
End Sub

Don wrote:

I have a specific row I want to print as a header for all but the last page.
I have tried using :

Totpages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
.PrintTitleRows = "$20:$20"
ActiveSheet.PrintOut From:=1, To:=Totpages-1
.PrintTitleRows = ""
ActiveSheet.PrintOut From:=Totpages, To:=Totpages

But the problem is that it will do two passes in preview. I need to have
the entire sheet formated properly in one pass so I can convert to a PDF
document.

The other problem is that the sheet can vary in length from 2 to 10 pages so
I cannot hardwire anything.

I really need a routine that can test what rows are in each page, or
possibly search for a unique keyword within the page. If found, insert
header (.PrintTitleRows = "$20:$20") otherwise do not do insertion
(.PrintTitleRows = "").

Thanks in advance




----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---

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
Header on first page and two sided printing srctr Excel Discussion (Misc queries) 0 February 12th 09 08:06 PM
Printing header row on each page GKW in GA Excel Discussion (Misc queries) 1 June 27th 07 05:52 PM
Prevent header from printing on 1st page? Bubba B Excel Discussion (Misc queries) 1 March 16th 06 07:09 PM
How do I stop printing a header after the third page? Val Excel Discussion (Misc queries) 1 September 16th 05 11:34 PM
Printing the page properties as header r_najafi Excel Discussion (Misc queries) 1 January 6th 05 02:59 PM


All times are GMT +1. The time now is 04:17 PM.

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

About Us

"It's about Microsoft Excel"