Ignore MsgBox if run by automation
In a general module (probably the one with your code) put in a public
variable
Public bRunByOpen as Boolean
in the workbook.Open Event then
Private Sub Workbook_Open()
bRunByOpen = True
mymacro
End Sub
In your current routine in a general module
dim res as variant
if not bRunByOpen then
res = MsgBox("Do you want to send this report?, vbYesNo)
else
res = vbYes
bRunByOpen = False
end if
if res = vbYes then
' code to send report
End if
--
Regards,
Tom Ogilvy
Tod wrote in message
...
I have something like this:
If MsgBox("Do you want to send this report?", vbYesNo) =
vbYes Then
'Code to send report
End If
When the code is being executed from a button on the
worksheet, it will give the user the choice. However, I
also have a script that opens this workbook each morning
and runs the same procedure. Is there a way I can have the
procedure know it's being run by a script and accept the
default (which I think is Yes)?
tod
|