1 | ; Example by big daddy |
---|
2 | |
---|
3 | ; Before running this: |
---|
4 | ; 1. Create a Word Document |
---|
5 | ; 2. Press Alt-F11 |
---|
6 | ; 3. Double Click "ThisDocument" |
---|
7 | ; 4. Paste the following macro |
---|
8 | ; 5. Saveas "ByRef.doc" |
---|
9 | |
---|
10 | ; Comment from big daddy: |
---|
11 | ; I would have expected the following to write "After" to the console, but instead it still has the value of "Before". |
---|
12 | |
---|
13 | #include <Word.au3> |
---|
14 | |
---|
15 | $vArg = "Before" |
---|
16 | $sFilePath = @ScriptDir & "\ByRef.doc" |
---|
17 | |
---|
18 | $oWordApp = _WordCreate($sFilePath, 0, 0) |
---|
19 | __WordMacroRun($oWordApp, "MacroTestByRef", $vArg) |
---|
20 | _WordQuit($oWordApp, 0) |
---|
21 | ConsoleWrite($vArg & @CR) |
---|
22 | |
---|
23 | Func __WordMacroRun(ByRef $o_object, $s_MacroName, ByRef $v_Arg1) |
---|
24 | $o_object.Run($s_MacroName, $v_Arg1) |
---|
25 | EndFunc ;==>__WordMacroRun |
---|