Footer

W

Walter Hofmann

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
 
J

Jim Rech

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.
 
W

Walter Hofmann

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!
 
J

Jim Rech

Hmmm.. Does a slightly dumbed down version work?

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

Walter Hofmann

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!
 

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