PDA

View Full Version : run autoit script from Word 2007 macro



Paul_BC
03-06-2012, 03:33 AM
Hi There

My knowledge of VBA is not very good.
I'd like to run an external Autoit script from within a Word macro.

So far I tried:

Sub BackupTest()
Dim runscript
runscript = Shell("C:\scripts\_backup.au3")
End Sub


This gives me a run-time Error 5 "Invalid Procedure Call or Argument".

Can anyone help?
Many thanks for a tip.
Paul

fumei
03-06-2012, 04:16 AM
Your filename starts with an underscore? _backup.au3 ??? Are you sure this is valid?

Paul_BC
03-06-2012, 04:34 AM
Okay I removed the underscore and the error message is unchanged.

fumei
03-06-2012, 10:50 PM
But the Shell argument must be an executable...not a data file. You have no executable.

Paul_BC
03-07-2012, 01:42 AM
I added the executable as follows and now it works.

Sub BackupTest()
Dim runscript
runscript = Shell("C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe C:\scripts\backup.au3")
End Sub
Many thanks.
Paul

fumei
03-07-2012, 04:46 PM
There you go.