Closing Microsoft Word
Moderators: Dorian (MJT support), JRL
Closing Microsoft Word
Have a mail merge macro that after it prints, I would like to close the document & Microsoft Word. However, when Word closes, I get the window: Do you want to save the changes you made to the document? Yes, No or Cancel. Anyone know how to automatically answer this?
Hi,
try to detect the window title (could be different from the one you see)
then
or
or
Check command reference for details.
Rgds,
Ernest
[/code]
try to detect the window title (could be different from the one you see)
Code: Select all
GetActiveWindow>window_title,X,Y
Code: Select all
MouseOver>window_title*,OK
LClick
Code: Select all
WaitWindowOpen>window_title
// repeat till you've reached the button to click on
Press Tab
Press Enter
Code: Select all
FindWindowWithText>Do you want to save the changes you made to the document?, setfocus_flag,result_variable,check_edits_flag
// repeat till you've reached the button to click on
Press Tab
Press Enter
Rgds,
Ernest
[/code]
- Marcus Tettmar
- Site Admin
- Posts: 7394
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
I have found that the following closes Microsoft Word without causing any prompts at all. I don't think it *should*, but it does!
CloseWindow>Microsoft Word*
Or, using the new WaitWindowChanged function, you can do this:
SetFocus>Microsoft Word*
Press ALT
Press F4
Release ALT
WaitWindowChanged>0
IfWindowOpen>Microsoft Word,cancelbox
Goto>cancelled
Label>cancelbox
Send>N
Label>cancelled
What this does is initiate the close sequence by sending ALT-F4 and then waits until the active window changes. It then checks to see if the new active window is the "Microsoft Word" dialog box. If so, it sends 'N' to press the 'No' button. Done.
I have found that the following closes Microsoft Word without causing any prompts at all. I don't think it *should*, but it does!
CloseWindow>Microsoft Word*
Or, using the new WaitWindowChanged function, you can do this:
SetFocus>Microsoft Word*
Press ALT
Press F4
Release ALT
WaitWindowChanged>0
IfWindowOpen>Microsoft Word,cancelbox
Goto>cancelled
Label>cancelbox
Send>N
Label>cancelled
What this does is initiate the close sequence by sending ALT-F4 and then waits until the active window changes. It then checks to see if the new active window is the "Microsoft Word" dialog box. If so, it sends 'N' to press the 'No' button. Done.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?