Save a Word document
Office menus has to be called using the keyboard shortcuts. Here is an example on Word.
You can find the corresponding script file under Script_Examples, sub-directory of scripts.
'launch Word
Shell(Chr$(34)+"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE"+Chr$(34),1)
'Type some text
UseWindow("WINWORD.EXE|_WwG|Document1|1",1)
SendKeys("Hello<Enter>")
'Menu options in Word are not using the Windows API functions,
'so we need to use the keyboard shortcuts
UseWindow("WINWORD.EXE|MsoCommandBar|Menu Bar")
'Shorcut Alt F for File menu
SendKeys("<Alt f>")
pause 5 ticks
'shortcut a for Save as option
SendKeys("a")
'A good practise is to delete first the file under which you want to save.
'At replay, whatever the file exists or not, you will never get a dialog box
'prompting for replacing the file.
If exist ("c:\wttest\test.doc") then
Kill("c:\wttest\test.doc")
EndIf
UseWindow("WINWORD.EXE|RichEdit20W|Save As|2",1)
SendKeys("c:\wttest\test.doc<Enter>")
CloseWindow("WINWORD.EXE|OpusApp|test.doc - Microsoft Word",1)