Footer

  • Thread starter Thread starter Walter Hofmann
  • Start date Start date
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
 
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.
 
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
 
Hmmm.. Does a slightly dumbed down version work?

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = "abc"
End Sub
 
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
 
Back
Top