themaccabee

Running Autoit from Excel VBA

3 posts in this topic

#1 ·  Posted

Hi

Im trying to run autoitscript from excel vba using a button click.

I wanted to run notepad1.au3 script from an excel sheet.

i copied the script into the same directory as excel sheet.

I wrote the following vba code to run the script.Everything seems to work fine, it takes the path file name etc accurately.

But instead of just running the script, an explorer window pops up ,asking me to locate the script i want to run.

I can browse to the location of the script through the explorer window and select the script file and it will run.

But i want it to run without opening an explorer window.

Any idea where could be the problem?

Thanks

VBA Code:

Sub Autoit()

Dim AutoItPath
Dim FileName As String
Dim FileName1 As String
FileName = ThisWorkbook.Path & "\notepad1.au3"
MsgBox (FileName)
AutoItPath = "C:\Program Files (x86)\AutoIt3" & "\AutoIt3.exe "
MsgBox (AutoItPath)
FileName1 = """" & AutoItPath & """" & "notepad1.au3"
MsgBox (FileName1)
runscript = Shell(FileName1)
End Sub

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Sorry please refer the below code, above one had a mistake

 

Sub Autoit()

Dim AutoItPath
Dim FileName As String
Dim FileName1 As String
FileName = ThisWorkbook.Path & "\notepad1.au3"
MsgBox (FileName)
AutoItPath = "C:\Program Files (x86)\AutoIt3" & "\AutoIt3.exe "
MsgBox (AutoItPath)
FileName1 = """" & AutoItPath & """" & """" & FileName & """"
MsgBox (FileName1)
runscript = Shell(FileName1)
End Sub


 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I notice there is no space between the quote wrapped paths.  What happens if you add a space between the exe and au3 paths and remove the extra space from the end of the AutoIt path?  Also, breaking out the exe from the program files dir seems erroneous to me, unless I am missing something...

AutoItPath = "C:\Program Files (x86)\AutoIt3\AutoIt3.exe"
FileName1 = """" & AutoItPath & """" & " " & """" & FileName & """"

 

Edited by spudw2k

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now