ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Footer (https://www.excelbanter.com/excel-programming/278445-footer.html)

Walter Hofmann

Footer
 
Hello

When using the following code in a BeforePrint subroutine, the footer is
not being updated, although the code runs without error:

With ActiveSheet.PageSetup
.LeftFooter = "&05" & strA & strC & strB & strS _
& Chr(10) & strFN
End With

What goes wrong?

Regards,
Walter Hofmann


Jim Rech

Footer
 
There is nothing wrong with the code per se. Are the variables, "strA",
etc. visible to this module? I'd guess not. If you put an "Option
Explicit" at the top of this module (and every module by selecting "Require
variable declaration" under Tools, Options, Editor in the VBE, that's what
the pros do), this problem would pop up immediately as an error.

If strA, etc. is defined in another module you have to declare them as
Public at the top of their module.

--
Jim Rech
Excel MVP



Walter Hofmann

Footer
 

Dear Jim

All str variables are defined in the subroutine and there is an option
explicit.

When I trace the code, the contents of the variables are correct, it's
just the assignment to the .footer that doesn't work.

Walter


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jim Rech

Footer
 
Hmmm.. Does a slightly dumbed down version work?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = "abc"
End Sub

--
Jim Rech
Excel MVP



Walter Hofmann[_2_]

Footer
 
The problem was that the code for the footer was in the BeforeSave
subroutine, which I called from the BeforePrint subroutine. I now have
made a 3rd subroutine which is being called from both BeforePrint and
BeforeSave. Like this all works as expected.

Walter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com