1

I've created a script in Autohotkey to automate webform entry from an excel workbook. The script is setup to enter the data from a line in excel into the form and then delete that row in excel. I am trying to create a loop in VBA to automate this task but am running into a few problems.

I can use shell to call the exe, but how can I make excel wait before it continues on(to then loop and call the exe again)

What is the best type of loop into this situation? I would like the exe to continue to be called until cell A3 is blank.

Thank you all for your help, it is much appreciated.

Daniel

Edit for David: I tried using the code from that link and get an error.

Sub run_code()


    Dim wsh As Object
    Set wsh = VBA.CreateObject("WScript.Shell")
    Dim waitOnReturn As Boolean: waitOnReturn = True
    Dim windowStyle As Integer: windowStyle = 1
    Dim errorCode As Integer

    wsh.Run("C:\Profiles\user\Desktop\macro3.exe", windowStyle, waitOnReturn)



End Sub
Daniel
  • 11
  • 1
  • 3
  • What excel must wait for before going to the next line? – Daniel Möller May 21 '13 at 20:12
  • possible duplicate of [excel vba wait for shell command to complete](http://stackoverflow.com/questions/15951837/excel-vba-wait-for-shell-command-to-complete) – David Zemens May 21 '13 at 20:12
  • See this: http://stackoverflow.com/a/15952009/1467082 – David Zemens May 21 '13 at 20:13
  • Dan, I would want excel to wait before looping to call the .exe again. – Daniel May 21 '13 at 20:19
  • David, I've edited the above question to show the code I tried from that link, I am getting a compile error. – Daniel May 21 '13 at 20:35
  • If you're using AutoHotKey, why not just put a msgbox("Paused") right before the end of your for/while loop and have the AutoHotKey script focus on Excel and press the "spacebar" to remove the msgbox. In VBA, msgbox are modal so they essentially pause the macro waiting for user input. – Michael May 21 '13 at 20:35
  • Hi Michael, would that require the user to hit the spacebar? Ideally the script will process the several thousand rows without any user action. – Daniel May 21 '13 at 20:39
  • Yes, "someone" would have to hit the spacebar, but you could just program that as the last line of the AutoHotKey code – Michael May 21 '13 at 20:53
  • That could work, I feel like this can be achieved with the shell and wait. I just can't seem to get it working. – Daniel May 21 '13 at 21:24
  • What does your Autohotkey script do? If its just submitting a web-form, with data from your workbook, why not let/make VBA do it for you instead of calling an external program? – NickSlash May 21 '13 at 23:38

0 Answers0