LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get a return value from a Word Macro for the Word Run Macro.vi?

How do I get a return value from a Word Macro for the Word Run Macro.vi? It has a output for a return value but I am lost on how to use it. Any examples available?
0 Kudos
Message 1 of 8
(4,354 Views)
If you right-click on the VI and select "Help", there will be a detailed explanation on how the function works.  It explains that parameters can be passed in and out of a macro as an array of variants.  Use the VIs in the "Cluster & Variant" palette to convert data to/from the proper data-types.
0 Kudos
Message 2 of 8
(4,334 Views)
I am having a problem with the macros themselves. When I search for help on the web I keep reading that macros cannot return values only functions return values. I have read the help files and have not seen any examples that show the vi returning a value.
0 Kudos
Message 3 of 8
(4,328 Views)
A regular macro in Word (or Excel, for that matter) is a "Sub", and hence has no return value, by definition. In order to have a return value you need a "Function".
Message 4 of 8
(4,316 Views)
I'm inexperienced so it is very confusing for me. A macro is a sub that cannot return a value but a function can. How do I run a macro that calls a function and have it read by the Word run macro vi? I have searched a few VBA books and cannot find an example.
0 Kudos
Message 5 of 8
(4,314 Views)
If you want a macro to return a value, you need to do it via the document.

In excel for example, you could set a cell to "=somefunction(value)".  Then after setting this, Excel will execute the function (which may be a macro in which case you may need to include the Execl file reference - PERSONL.XLS$ etc.) and update the value.

You then go back and read the cell.Value to get the result.

In Word I would imagine it's similar, but you'd probable be best working within a cell of a table to make referencing easier, or use a field function or whatever.  Like I said, less experience in Word.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 6 of 8
(4,300 Views)
Things are becoming a little bit clearer for me. The terminology was a little confusing. I was thinking that in order to call a macro from the Word Run Macro.vi it had to be a sub and listed in the documents list of macros. I created a function that returned a value and called it using the Word Run Macro.vi and successfully returned the data needed. I'm learning, slow but sure. 
0 Kudos
Message 7 of 8
(4,291 Views)
Did you manage to get the value back directly from the "Run Macro" command, or was it via something else?

I'd like to see an example 'cause I didn'0t think this was possible.....

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 8 of 8
(4,282 Views)