Turpis
Programmer
- Apr 16, 2002
- 151
I have a problem that stumps me. I have provided enough code for you see what is happening. This code is in an add-in. The code works perfectly on: Win2000/Off2000, Win2000/OffXP, and on a virtual machine WinXP/Off2000, but the new computers from Dell that we got have WinXP/Off2000 and will not run the Workbook_BeforePrint at all. I have a virtual machine setup exactly the same as the Dell's and it works fine. I have put msgboxes in the Private Sub Workbook_BeforePrint of the add-in and no msgbox appears. What could possible be going on here...I will considered all theories at this point, including aliens are interfering with my code "because it is fun".
-------------------
in ThisWorkbook
-------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
InitializeApp
End Sub
Private Sub Workbook_Open()
InitializeApp
End Sub
-------------------
in a module
-------------------
Dim x As New AppEventClassModule
Sub InitializeApp()
Set x.App = Application
End Sub
-------------------
in a ClassModule
-------------------
Public WithEvents App As Application
Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
Dim ans, ans2, ans3
duh1 = Wb.Name
duh2 = Left(duh1, 8)
CMName = Application.UserName
If Not duh2 = "report_2" Then
GoTo theEnd
End If
Select Case CMName
Case "jcollins"
GoTo pRentSR
Case "jyocum"
GoTo pRentAW
Case "lshannon"
GoTo pRentBoth
Case "sgray"
GoTo pRentAW
Case Else
GoTo theEnd
End Select ' thus ends this case section
' this section fires off an email to susan and others
pRentSR:
ans = MsgBox("Do you wish to email Ship Sheet?", vbYesNo, "Email Question"
If ans = vbYes Then
GoTo emailshipsheetSR
End If
ans3 = MsgBox("Would you like to print a copy?", vbYesNo, "Print Question"
If Not ans3 = vbYes Then
Cancel = True
End If
GoTo theEnd
emailshipsheetSR:
ActiveSheet.Copy
blah, blah, blah...you get the idea
-----------------
Charles
Walden's Machine, Inc.
Quality/Office Developer
-------------------
in ThisWorkbook
-------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
InitializeApp
End Sub
Private Sub Workbook_Open()
InitializeApp
End Sub
-------------------
in a module
-------------------
Dim x As New AppEventClassModule
Sub InitializeApp()
Set x.App = Application
End Sub
-------------------
in a ClassModule
-------------------
Public WithEvents App As Application
Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
Dim ans, ans2, ans3
duh1 = Wb.Name
duh2 = Left(duh1, 8)
CMName = Application.UserName
If Not duh2 = "report_2" Then
GoTo theEnd
End If
Select Case CMName
Case "jcollins"
GoTo pRentSR
Case "jyocum"
GoTo pRentAW
Case "lshannon"
GoTo pRentBoth
Case "sgray"
GoTo pRentAW
Case Else
GoTo theEnd
End Select ' thus ends this case section
' this section fires off an email to susan and others
pRentSR:
ans = MsgBox("Do you wish to email Ship Sheet?", vbYesNo, "Email Question"
If ans = vbYes Then
GoTo emailshipsheetSR
End If
ans3 = MsgBox("Would you like to print a copy?", vbYesNo, "Print Question"
If Not ans3 = vbYes Then
Cancel = True
End If
GoTo theEnd
emailshipsheetSR:
ActiveSheet.Copy
blah, blah, blah...you get the idea
-----------------
Charles
Walden's Machine, Inc.
Quality/Office Developer