Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 32
Default Print preview error from BeforePrint macro

Using the WONDERFUL knowledge this board is loaded with I was able to answer
a question that came up in my training class. How do you get multiple lines
in your footers and how do you adjust the font size.

I came up with this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = "&07" & ActiveWorkbook.FullName & vbLf
& vbLf
End Sub

Using this they can put the page numbering info in the center footer center
(via the menus) and then the macro will put the full path name in a smaller
font (it's a HUGE path name) in the left section of the footer everything is
great.

This prints perfectly ... but when I try to print preview the sheet I get
the following error message:

Method 'FullName' of object '_Workbook' failed

If I pick debug it goes on just fine but I'd rather not have the error.

Is there someplace else I can put the macro that wouldn't cause this error
on previewing??



  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Print preview error from BeforePrint macro

Your code worked ok for me just as you wrote it.

You sure it's that line that's causing the error.

ps. I'd use this instead:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = "&07" & Me.FullName & vbLf & vbLf
End Sub

Me is a special keyword that refers to the thing that owns the code. In this
case, it means the workbook that you're printing (probably).

pps. Actually, I'd specify the sheets that I wanted to have that footer. You
can print other stuff besides just the activesheet.

If you wanted all the sheets to have that footer:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
dim sh as object
for each sh in me.sheets
sh.PageSetup.LeftFooter = "&07" & me.FullName & vbLf & vbLf
next sh
End Sub

LauriS wrote:

Using the WONDERFUL knowledge this board is loaded with I was able to answer
a question that came up in my training class. How do you get multiple lines
in your footers and how do you adjust the font size.

I came up with this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = "&07" & ActiveWorkbook.FullName & vbLf
& vbLf
End Sub

Using this they can put the page numbering info in the center footer center
(via the menus) and then the macro will put the full path name in a smaller
font (it's a HUGE path name) in the left section of the footer everything is
great.

This prints perfectly ... but when I try to print preview the sheet I get
the following error message:

Method 'FullName' of object '_Workbook' failed

If I pick debug it goes on just fine but I'd rather not have the error.

Is there someplace else I can put the macro that wouldn't cause this error
on previewing??


--

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
Excel spreadsheet print preview error "nothing to print" ann Excel Discussion (Misc queries) 8 August 23rd 06 08:58 PM
Print Preview Macro Emanuel Violante Excel Discussion (Misc queries) 1 June 2nd 06 11:28 AM
Macro to include Close Print Preview Vic Charts and Charting in Excel 1 January 9th 06 01:06 AM
BeforePrint macro Steve O Excel Discussion (Misc queries) 4 September 21st 05 01:09 AM
In print preview I can see all of the error value why is this and. Jacqueline Excel Discussion (Misc queries) 2 December 9th 04 11:18 PM


All times are GMT +1. The time now is 08:19 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"