Visio Guy

Visio Discussions => Programming & Code => Topic started by: lindir on July 15, 2014, 08:50:09 AM

Title: Answer Ok to a MsgBox
Post by: lindir on July 15, 2014, 08:50:09 AM
Hello guys!

I have a macro to drop shape on my visio drawing but for each shape a pop up appear and my code stop running.
The msgbox is an OK/cancel and and juste want to answer OK

Do you have an idea to automtically answer OK to a msgbox? or to avoid this msgbox from appear?

I try SendKeys {ENTER} but my code stop before reaching this command so it doesn't work :(

Thanks!!
Title: Re: Answer Ok to a MsgBox
Post by: Surrogate on July 15, 2014, 09:38:01 AM
Just delete code with msgbox  :)
Title: Re: Answer Ok to a MsgBox
Post by: Yacine on July 15, 2014, 05:37:01 PM
funny
Title: Re: Answer Ok to a MsgBox
Post by: lindir on July 17, 2014, 06:02:54 AM
Ahah wish it could be so simple..
The problem is that the MsgBox isn't in my code. Visio generetat it to aske me to do some settings on the shape I dropped with my code
Title: Re: Answer Ok to a MsgBox
Post by: Surrogate on July 17, 2014, 08:38:50 AM
try add time delay like as
    PauseTime = 5    ' Set duration.
    Start = Timer    ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
    Loop
        SendKeys "{F4}", True
Title: Re: Answer Ok to a MsgBox
Post by: Paul Herber on July 17, 2014, 08:52:32 AM
Have a look at:
http://msdn.microsoft.com/en-us/library/office/ff767782%28v=office.15%29.aspx
or
http://msdn.microsoft.com/en-us/library/office/aa215114%28v=office.11%29.aspx
or
http://www.vbforums.com/showthread.php?420883-FAQ-s-OD-How-do-supress-or-automatically-choose-Alerts-Prompts-in-a-drawing

Hope this helps.
Title: Re: Answer Ok to a MsgBox
Post by: lindir on July 17, 2014, 02:40:36 PM
So much Thanks paul, I just add this line
Application.AlertResponse=1 

And all my problems are solved!


Merci!!
Title: Re: Answer Ok to a MsgBox
Post by: Paul Herber on July 17, 2014, 02:42:51 PM
All of them?  Marvellous!!  :)
Title: Re: Answer Ok to a MsgBox
Post by: lindir on July 17, 2014, 02:46:03 PM
All of them for this macro at least!!
This line doesn't pay my rent unfortunately  ;D