Hi , I have written this code so it closes Excel than does something else.
It worked when I had Excel open but did not when I had no excel file open. Please help
ifWindowOpen>Microsoft Excel*,closeex
label>closeex
CloseWindow>Microsoft Excel*
goto>closecpms
label>closecpms
ifWindowOpen>CPMS*,endline
wait> 30
ExecuteFile>C:\CPMSWin2\CPMSUpdater.exe
label>endline
Condition ignored
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This code will try to close Excel whether or not Excel is already open.
Your logic says if excel is open goto the closeex label. It it is not open go to the next line ... which IS the closeex label! So you ALWAYS go to the closeex label!
You might as well remove the IfWindowOpen line as it makes no difference.
You also have a line that says Goto>closecpms yet Label>closecpms is on the very next line ... not sure what the point of that is.
You also have an erroneous space in the Wait command.
I expect you might be intending to do something like:
ifWindowOpen>Microsoft Excel*,closeex
goto>closecpms
label>closeex
CloseWindow>Microsoft Excel*
label>closecpms
ifWindowOpen>CPMS*,endline
wait>30
ExecuteFile>C:\CPMSWin2\CPMSUpdater.exe
label>endline
If you have 7.3 or later you can simplify this logic:
IfWindowOpen>Microsoft Excel*
CloseWindow>Microsoft Excel*
Endif
IfWindowOpen>CMPS*
//Do nothing
ELSE
wait>30
ExecuteFile>C:\CPMSWin2\CPMSUpdater.exe
ENDIF
Your logic says if excel is open goto the closeex label. It it is not open go to the next line ... which IS the closeex label! So you ALWAYS go to the closeex label!
You might as well remove the IfWindowOpen line as it makes no difference.
You also have a line that says Goto>closecpms yet Label>closecpms is on the very next line ... not sure what the point of that is.
You also have an erroneous space in the Wait command.
I expect you might be intending to do something like:
ifWindowOpen>Microsoft Excel*,closeex
goto>closecpms
label>closeex
CloseWindow>Microsoft Excel*
label>closecpms
ifWindowOpen>CPMS*,endline
wait>30
ExecuteFile>C:\CPMSWin2\CPMSUpdater.exe
label>endline
If you have 7.3 or later you can simplify this logic:
IfWindowOpen>Microsoft Excel*
CloseWindow>Microsoft Excel*
Endif
IfWindowOpen>CMPS*
//Do nothing
ELSE
wait>30
ExecuteFile>C:\CPMSWin2\CPMSUpdater.exe
ENDIF
Last edited by Marcus Tettmar on Thu Feb 16, 2006 7:12 pm, edited 1 time in total.
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?
Re: Condition ignored
Thanks it works !
AD
AD
dagdag wrote:Hi , I have written this code so it closes Excel than does something else.
It worked when I had Excel open but did not when I had no excel file open. Please help
ifWindowOpen>Microsoft Excel*,closeex
label>closeex
CloseWindow>Microsoft Excel*
goto>closecpms
label>closecpms
ifWindowOpen>CPMS*,endline
wait> 30
ExecuteFile>C:\CPMSWin2\CPMSUpdater.exe
label>endline