Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi community,
When we execute a macro and it fails,the per default thing that happens is that the macro script is shown.
My question now, is there a way, instead of this behaviour, a Message Box is shown (an alert) saying that the macro failed to execute? or/AND an email is sent saying that the MACRO FAILED TO EXECUTE?
Thank you a lot !
Hi,
Create a dummy variable as vA in Variable Overview and go to Document Properties --> Triggers --> OnPostReload --> add actions (b4 Run Macro) --> Set Variable --> Variable = vA , Value = 1
Below Set Variable vA, add action Run Macro --> Macro Name = Check
Try this code in macro (Tools --> Edit Module),
Sub Check
If (ActiveDocument.Evaluate("=$(vA)"))=1 then
'Your Code
'
'
'
Set Var1 = ActiveDocument.Variables("vA")
Var1.SetContent "0",true
else
Msgbox("Macro Failed")
End If
end sub
Hi ,
You want to sent email means through QMC or just reload. As QMC will not execute macros.
Have a look into this,
HTH,
Hirish
Hi,
Create a dummy variable as vA in Variable Overview and go to Document Properties --> Triggers --> OnPostReload --> add actions (b4 Run Macro) --> Set Variable --> Variable = vA , Value = 1
Below Set Variable vA, add action Run Macro --> Macro Name = Check
Try this code in macro (Tools --> Edit Module),
Sub Check
If (ActiveDocument.Evaluate("=$(vA)"))=1 then
'Your Code
'
'
'
Set Var1 = ActiveDocument.Variables("vA")
Var1.SetContent "0",true
else
Msgbox("Macro Failed")
End If
end sub
if I have this;
sub Distribute
bla bla
end sub
and then add :
Sub Check
If (ActiveDocument.Evaluate("=$(vA)"))=1 then
'//here is my code
sub Distribute
bla bla
end sub
'//////
Set Var1 = ActiveDocument.Variables("vA")
Var1.SetContent "0",true
else
Msgbox("Macro Failed")
End If
end sub
=> I have a syntax error !
How to surround my sub with the check sub?
Hi Omar,
Add your code without including Sub Distribute and end sub..
That's really good ! and what if with the alert, I want to send an email just for me with the object : macro failure and a message: the macro has failed?
Hi Omar,
I want to work on that error message as mail to User.
Regards,
Sri
Great !