LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the return value from Excel Run Macro vi

The "Excel Run Macro" vi in LV8  provides an output labeled 'return value'.  I don't understand how to get the return value out of excel and into the calling vi.  Does one assign this value in the called macro and if so what command or syntax is needed?  I'm a LV beginner working on my first program and am no expert in Excel.  I've looked at this for a couple of hours and the solution is not evident.  thanks for any pointers.  Mike
0 Kudos
Message 1 of 5
(3,475 Views)
Doh.  Okay, got it figured out.  thanks for looking
0 Kudos
Message 2 of 5
(3,461 Views)

Can you post what the solution ended up being?  It would help people who encounter this problem in the future.  And it would satisfy my curiosity... 🙂

-D

0 Kudos
Message 3 of 5
(3,454 Views)
Ah Darran, I spoke too soon.  what popped into my head as the solution was simply a senior moment.  Not wanting to bother unnecessarily I posted before actually trying the idea.  Love being 60.  So once again I'm open for suggestions.  I just want to be able to get the row location of the cursor in an opened Excel report.  Right now I'm using a local variable in a couple of places in my vi to keep track but using a returned value from excel seemed more elegant.  Mike, who is confused as ever.
0 Kudos
Message 4 of 5
(3,449 Views)

Hi Mike,

I don't know much about VBA, so I'm not sure how to write a macro in such a way that it has a return value.  There is a macro example that ships with the Report Generation Toolkit ([LabVIEW]\examples\office\Word Examples.llb\Run Macro on Word Table.vi), but it doesn't have a return value.  If you have a macro that successfully gives you a return value, you just need to convert it from a variant to the proper datatype.  I'm guessing in your case, it would be an integer if it returns the row number, or a string if it returns the Excel-specific coordinates (like B2, A13, etc.).  You can use the Variant to Data function (on the ActiveX palette) to convert variants to the proper datatypes.

I don't know much more to tell you.  Let me know if you make any progress.

-D

0 Kudos
Message 5 of 5
(3,440 Views)