Jump to content

Passing Parameters to Word so they are used by VBA


Recommended Posts

I cannot find any answers to this.

My AutoIt script should:

1. AutoIt read a row of data in Excel --> Working

2. Pull a Word document from our document database & open it --> Working

3. Run a Word macro that uses the data from Excel that AutoIt read

I am having trouble with Step 3. When I run the word macro with parameters it doesn't work.

Note: a Word document is opened when I run this.

CODE

#include <Word.au3>

Opt("WinWaitDelay", 250)

Opt("WinTitleMatchMode", 4)

Opt("WinDetectHiddenText", 1)

Opt("MouseCoordMode", 0)

Global $hWnd, $myClip, $style, $GWL_EXSTYLE, $iResponse, $v_Arg1, $v_Arg2, $v_Arg3

Global $FilePath, $oExcel, $title, $myRow, $myColumn, $myECM, $myByPass, $hWndsCREEN2, $hWndsCREEN1

$v_Arg1 = "New"

$v_Arg2 = "6"

$v_Arg3 = "ecm5052895.B"

$oWordApp = ObjGet("", "Word.Application")

$oWordDoc = ObjName("", "Word.Application.Documents")

WinWait("[REGEXPTITLE:^.* - Microsoft Word$]", "")

If Not WinActive("[REGEXPTITLE:^.* - Microsoft Word$]", "") Then WinActivate("[REGEXPTITLE:^.* - Microsoft Word$]", "")

WinWaitActive("[REGEXPTITLE:^.* - Microsoft Word$]", "")

$oWordDoc = WinActivate("[REGEXPTITLE:^.* - Microsoft Word$]", "")

_WordMacroRun($oWordApp, "StartHereDocs", $v_Arg1, $v_Arg2, $v_Arg3)

It does not run the macro when the parameters listed. I does work if I leave them out. But I need the information sent to Word. What am I missing that it isn't running correctly?

That does bring up a 2nd question. How does Word get the parameters? Is there a VBA code for this?

Thanks for any help on either question.

Kristine

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...