View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dan E[_2_] Dan E[_2_] is offline
external usenet poster
 
Posts: 102
Default Ignore MsgBox if run by automation

My suggestion would be to make a function that takes an argument and does
everything you want it to ie:
Private Function MyFunction(Send as Boolean)
code . . .
If Send = True then
code to send . . .
End If
code . . .
End Function

Then for your button
Private Sub myButton_Click()
If MsgBox("Do you want to send this report?", vbYesNo) = vbYes Then
MyFunction Send:=TRUE
Else
MyFunction Send:=FALSE
End If
End Sub

For your other code
MyFunction Send:=TRUE

Dan E

"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