E
Ernest L. Lippert
The BeforePrint code below, when placed in This Workbook object, works fine.
However, when it is saved as an xla file to create an Add-In, it doesn't
work in another workbook even though the Add-In "FooterYesNo" is checked in
the Add-In Manager.
What haven't I done correctly?
Regards,
Ernie
*********************************
Option Explicit
Dim Ans As String
Dim sht As Variant
Private Sub Workbook_BeforePrint(Cancel As Boolean)
'Based on John Walkenbach, Microsoft Excel 2000 Power
'Programming with VBA, ISBN 0-7654-3263-4 (1999) p. 527
Ans = MsgBox("Add path to footer?", vbYesNo + vbQuestion, "Tell
Me")
If Ans = vbNo Then
For Each sht In ThisWorkbook.Sheets
sht.PageSetup.LeftFooter = ""
Next sht
Else: For Each sht In ThisWorkbook.Sheets
sht.PageSetup.LeftFooter = "&8" & LCase(ThisWorkbook.FullName)
Next sht
End If
Ans = MsgBox("Print this sheet?", vbYesNo + vbQuestion, "Tell me")
If Ans = vbNo Then Cancel = False
End Sub
********************-30*************
However, when it is saved as an xla file to create an Add-In, it doesn't
work in another workbook even though the Add-In "FooterYesNo" is checked in
the Add-In Manager.
What haven't I done correctly?
Regards,
Ernie
*********************************
Option Explicit
Dim Ans As String
Dim sht As Variant
Private Sub Workbook_BeforePrint(Cancel As Boolean)
'Based on John Walkenbach, Microsoft Excel 2000 Power
'Programming with VBA, ISBN 0-7654-3263-4 (1999) p. 527
Ans = MsgBox("Add path to footer?", vbYesNo + vbQuestion, "Tell
Me")
If Ans = vbNo Then
For Each sht In ThisWorkbook.Sheets
sht.PageSetup.LeftFooter = ""
Next sht
Else: For Each sht In ThisWorkbook.Sheets
sht.PageSetup.LeftFooter = "&8" & LCase(ThisWorkbook.FullName)
Next sht
End If
Ans = MsgBox("Print this sheet?", vbYesNo + vbQuestion, "Tell me")
If Ans = vbNo Then Cancel = False
End Sub
********************-30*************