Insert Text at Bottom of Last Page

S

Steve

Thanks in advance to everyone who tries to help me with this.

I have a spreadsheet that serves as a quotation page for services to
be provided. The number of pages of the quotation varies depending on
the amount of services.

My problem is how to automatically insert a disclaimer at the bottom
of only the last page, just above the footer. I have page numbers
printing in the footer.

When I select File, Page Setup and hit Enter, the dotted lines appear
to show where the page will end, so I can currently cut and paste the
five lines of text just above the dotted line. I would like to find a
way to automatically locted that dotted line (last row printing on the
last page) and insert the lines by using the BeforePrint event.

Any ideas?

Thanks,

Steve
 
W

William

Hi Steve

Try the following which places your disclaimer 2 cells below the last cell
in column A, sets the print area, prints the sheet and then removes the
disclaimer. I have assumed the columns to print are Columns A to G.

Sub PrintDisclaimer()
Dim x As String
'Amend following line as necessary
x = "This is my disclaimer"
With Sheets("Sheet1")
..Range("A65000").End(xlUp).Offset(2, 0) = x
..PageSetup.PrintArea = .Range(.Range("A1"), _
..Range("A" & Rows.Count).End(xlUp).Offset(0, 5)).Address
..Printout
..Range("A65000").End(xlUp).ClearContents
End With
End Sub

--
XL2002
Regards

William

(e-mail address removed)

| Thanks in advance to everyone who tries to help me with this.
|
| I have a spreadsheet that serves as a quotation page for services to
| be provided. The number of pages of the quotation varies depending on
| the amount of services.
|
| My problem is how to automatically insert a disclaimer at the bottom
| of only the last page, just above the footer. I have page numbers
| printing in the footer.
|
| When I select File, Page Setup and hit Enter, the dotted lines appear
| to show where the page will end, so I can currently cut and paste the
| five lines of text just above the dotted line. I would like to find a
| way to automatically locted that dotted line (last row printing on the
| last page) and insert the lines by using the BeforePrint event.
|
| Any ideas?
|
| Thanks,
|
| Steve
|
 
W

William

Steve

I didn't read your post fully. To use the code in conjunction with the
"BeforePrint" event, place the following in the "ThisWorkbook" module

Private Sub Workbook_BeforePrint(Cancel As Boolean)
'Amend sheet name as necessary
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
PrintDisclaimer
End If
End Sub


.... and place this in a general module

Sub PrintDisclaimer()
'Amend sheet name, disclaimer, etc as necessary
Application.EnableEvents = False
Dim x As String
x = "This is my disclaimer"
With Sheets("Sheet1")
..Range("A65000").End(xlUp).Offset(2, 0) = x
..PageSetup.PrintArea = .Range(.Range("A1"), _
..Range("A" & Rows.Count).End(xlUp).Offset(0, 5)).Address
..PrintOut
..Range("A65000").End(xlUp).ClearContents
End With
Application.EnableEvents = True
End Sub

--
XL2002
Regards

William

(e-mail address removed)

| Hi Steve
|
| Try the following which places your disclaimer 2 cells below the last cell
| in column A, sets the print area, prints the sheet and then removes the
| disclaimer. I have assumed the columns to print are Columns A to G.
|
| Sub PrintDisclaimer()
| Dim x As String
| 'Amend following line as necessary
| x = "This is my disclaimer"
| With Sheets("Sheet1")
| .Range("A65000").End(xlUp).Offset(2, 0) = x
| .PageSetup.PrintArea = .Range(.Range("A1"), _
| .Range("A" & Rows.Count).End(xlUp).Offset(0, 5)).Address
| .Printout
| .Range("A65000").End(xlUp).ClearContents
| End With
| End Sub
|
| --
| XL2002
| Regards
|
| William
|
| (e-mail address removed)
|
| | | Thanks in advance to everyone who tries to help me with this.
| |
| | I have a spreadsheet that serves as a quotation page for services to
| | be provided. The number of pages of the quotation varies depending on
| | the amount of services.
| |
| | My problem is how to automatically insert a disclaimer at the bottom
| | of only the last page, just above the footer. I have page numbers
| | printing in the footer.
| |
| | When I select File, Page Setup and hit Enter, the dotted lines appear
| | to show where the page will end, so I can currently cut and paste the
| | five lines of text just above the dotted line. I would like to find a
| | way to automatically locted that dotted line (last row printing on the
| | last page) and insert the lines by using the BeforePrint event.
| |
| | Any ideas?
| |
| | Thanks,
| |
| | Steve
| |
|
|
 
T

Tom Ogilvy

since your printing in the BeforePrint event, wouldn't you need to disable
events?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
'Amend sheet name as necessary
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
application.EnableEvents = False
PrintDisclaimer
application.enableEvents = True
End If
End Sub
 
W

William

Hi Tom

I disabled events in the "PrintDisclaimer" macro.

I tested the code and it appeared to work.

--
XL2002
Regards

William

(e-mail address removed)

| since your printing in the BeforePrint event, wouldn't you need to disable
| events?
|
| Private Sub Workbook_BeforePrint(Cancel As Boolean)
| 'Amend sheet name as necessary
| If ActiveSheet.Name = "Sheet1" Then
| Cancel = True
| application.EnableEvents = False
| PrintDisclaimer
| application.enableEvents = True
| End If
| End Sub
|
| --
| Regards,
| Tom Ogilvy
|
|
| | > Steve
| >
| > I didn't read your post fully. To use the code in conjunction with the
| > "BeforePrint" event, place the following in the "ThisWorkbook" module
| >
| > Private Sub Workbook_BeforePrint(Cancel As Boolean)
| > 'Amend sheet name as necessary
| > If ActiveSheet.Name = "Sheet1" Then
| > Cancel = True
| > PrintDisclaimer
| > End If
| > End Sub
| >
| >
| > ... and place this in a general module
| >
| > Sub PrintDisclaimer()
| > 'Amend sheet name, disclaimer, etc as necessary
| > Application.EnableEvents = False
| > Dim x As String
| > x = "This is my disclaimer"
| > With Sheets("Sheet1")
| > .Range("A65000").End(xlUp).Offset(2, 0) = x
| > .PageSetup.PrintArea = .Range(.Range("A1"), _
| > .Range("A" & Rows.Count).End(xlUp).Offset(0, 5)).Address
| > .PrintOut
| > .Range("A65000").End(xlUp).ClearContents
| > End With
| > Application.EnableEvents = True
| > End Sub
| >
| > --
| > XL2002
| > Regards
| >
| > William
| >
| > (e-mail address removed)
| >
| > | > | Hi Steve
| > |
| > | Try the following which places your disclaimer 2 cells below the last
| cell
| > | in column A, sets the print area, prints the sheet and then removes
the
| > | disclaimer. I have assumed the columns to print are Columns A to G.
| > |
| > | Sub PrintDisclaimer()
| > | Dim x As String
| > | 'Amend following line as necessary
| > | x = "This is my disclaimer"
| > | With Sheets("Sheet1")
| > | .Range("A65000").End(xlUp).Offset(2, 0) = x
| > | .PageSetup.PrintArea = .Range(.Range("A1"), _
| > | .Range("A" & Rows.Count).End(xlUp).Offset(0, 5)).Address
| > | .Printout
| > | .Range("A65000").End(xlUp).ClearContents
| > | End With
| > | End Sub
| > |
| > | --
| > | XL2002
| > | Regards
| > |
| > | William
| > |
| > | (e-mail address removed)
| > |
| > | | > | | Thanks in advance to everyone who tries to help me with this.
| > | |
| > | | I have a spreadsheet that serves as a quotation page for services to
| > | | be provided. The number of pages of the quotation varies depending
on
| > | | the amount of services.
| > | |
| > | | My problem is how to automatically insert a disclaimer at the bottom
| > | | of only the last page, just above the footer. I have page numbers
| > | | printing in the footer.
| > | |
| > | | When I select File, Page Setup and hit Enter, the dotted lines
appear
| > | | to show where the page will end, so I can currently cut and paste
the
| > | | five lines of text just above the dotted line. I would like to find
a
| > | | way to automatically locted that dotted line (last row printing on
the
| > | | last page) and insert the lines by using the BeforePrint event.
| > | |
| > | | Any ideas?
| > | |
| > | | Thanks,
| > | |
| > | | Steve
| > | |
| > |
| > |
| >
| >
|
|
 
W

William

Hi Steve

Please post directly to the ng rather than email me directly so anyone
interested can follow the thread.

If my previous post didn't do what you want as the "Discalimer" appeared too
high, you may want to try....

Private Sub Workbook_BeforePrint(Cancel As Boolean)
'Amend sheet name as necessary
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
PrintDisclaimer
End If
End Sub


Sub PrintDisclaimer()
'Amend sheet name, disclaimer, etc as necessary
Application.EnableEvents = False
Dim x As String
Dim Cmd As String, i As Integer
x = "This is my disclaimer"
With Sheets("Sheet1")
..PageSetup.CenterFooter = ""
..PageSetup.LeftFooter = "&8" & "Page &P of &N"
..PageSetup.PrintArea = .Range(.Range("A1"), _
..Range("A" & Rows.Count).End(xlUp).Offset(0, 5)).Address
Cmd = "GET.DOCUMENT(50,""" & ActiveSheet.Name & """)"
i = Application.ExecuteExcel4Macro(Cmd)
..PrintOut From:=1, To:=i - 1
..PageSetup.CenterFooter = "&8" & x
..PrintOut From:=i, To:=i
End With
Application.EnableEvents = True
End Sub

--
XL2002
Regards

William

(e-mail address removed)

| Thanks in advance to everyone who tries to help me with this.
|
| I have a spreadsheet that serves as a quotation page for services to
| be provided. The number of pages of the quotation varies depending on
| the amount of services.
|
| My problem is how to automatically insert a disclaimer at the bottom
| of only the last page, just above the footer. I have page numbers
| printing in the footer.
|
| When I select File, Page Setup and hit Enter, the dotted lines appear
| to show where the page will end, so I can currently cut and paste the
| five lines of text just above the dotted line. I would like to find a
| way to automatically locted that dotted line (last row printing on the
| last page) and insert the lines by using the BeforePrint event.
|
| Any ideas?
|
| Thanks,
|
| Steve
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top