From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running a Excel macro from a open workbook?

Solved!
Go to solution

Hello all,

I'm relatively new to Lab View and the Lab VIEW forumsI have searched the forums and Knowledge Database with results that don't really answer my questionI've download every LV/Excel example and llb I can find... dug through them and have attempted to familiarize myself with the LV/Excel relationship with marginal results.

 

Basically what I'm trying to do is run a Excel macro in a workbook that is already open and running...  all of the examples I've found force you to open the Excel workbook, which is problematic if the workbook is already openI have a VI that'll open my workbook and run the macro I've specified, but when I try to strip out the "open" portion it blows up

 

I pulled the "Excel Macro Example.VI" from NI Example finder, which once again doesn't work if the workbook is already openIt seems to me that the main issue is that there is not another option other than the "Automation Open.VI"   I do not have the reports tool kit so that may be the issue... don't know since I don't know what it contains

 

I've attached the one that opens my sheet and runs the macro (excel_run_macro.vi).  I would be very grateful if someone that understands the ties between LV and Excel would take a look and possibly point me in the general direction of how to run the macro without trying to open Excel again.

 

Thanks!

Chad

 

0 Kudos
Message 1 of 7
(4,696 Views)

Sorry guys, I forgot to metion that I'm using LV2009 and Excel 03.

THX

C

0 Kudos
Message 2 of 7
(4,680 Views)
Solution
Accepted by topic author chuggins143

the problem is that you keep trying to open the workbook when it is already open. in the attached code you will that I search to see if the workbook is open. If it is then I set it to be the active workbook and run the macro. If not then i open it and then run the macro.

 

try the attached code and see if it works for you. You will hace to make sure that all the references are closed and that the comparison functionality works for you. I just kinda hacked this together as a proof of concept for you.

Message Edited by Joe_H on 11-17-2009 12:04 PM



Joe.
"NOTHING IS EVER EASY"
Message 3 of 7
(4,647 Views)

Excellent!  Joe you are the man!   I just had to go in and make sure the path and macro name matched my names and it works like a charm!

 

Thank you!

Chad

0 Kudos
Message 4 of 7
(4,633 Views)

Glad i could help.

 

For more information and some sample VI's and tool kits, you can go to the excel board




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 5 of 7
(4,630 Views)

Hi, i am trying to run the excel macro using labview and extract the updated "refreshed" data from excel back to labview. However, i am facing several errors. anyone out there could enlighten me? thanks!

0 Kudos
Message 6 of 7
(3,387 Views)

You probably should've started a new thread rather than tacking onto a 3 year old thread.

 

It is difficult to help when you say you have errors, but fail to tell us what those errors are.

 

I'm suspicious of they way those Excel references are being bundled, unbundled, and rebundled all over the VI.  What is the point of all of that.

0 Kudos
Message 7 of 7
(3,381 Views)