From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Excel ActiveX Workbook VBProject Property

Solved!
Go to solution

Hello All,

   I've created different LabVIEW VI's that import data from excel but I would like to create one that runs a macro (can't use the Report Generation Toolbox).  I have the basic code but I'm not sure how to access the VBProject property of the Workbook I'm referencing.  Does anyone know how I obtain this block?

 

LV2.JPG

0 Kudos
Message 1 of 13
(4,498 Views)

@DrNO23 wrote:

Hello All,

   I've created different LabVIEW VI's that import data from excel but I would like to create one that runs a macro (can't use the Report Generation Toolbox).  I have the basic code but I'm not sure how to access the VBProject property of the Workbook I'm referencing.  Does anyone know how I obtain this block?

 

LV2.JPG


Learn how to translate VBA to LabVIEW.  https://support.microsoft.com/en-us/kb/194611

0 Kudos
Message 2 of 13
(4,488 Views)

nyc,

   I'm not exactly sure what you mean.  The point of writting this VI is so that I can vary a couple of parameters and then translate that into a macro which will completely format an Excel Workbook for me but I just can't seem to find the 'Workbook' object that has the VBProject property listed under it.  

0 Kudos
Message 3 of 13
(4,483 Views)
Solution
Accepted by topic author DrNO23

@DrNO23 wrote:

nyc,

   I'm not exactly sure what you mean.  The point of writting this VI is so that I can vary a couple of parameters and then translate that into a macro which will completely format an Excel Workbook for me but I just can't seem to find the 'Workbook' object that has the VBProject property listed under it.  


Post your VI.

 

The fact that you cannot find the VBProject property indicates an error in your code.

 

You need to know understand the Excel Object Model to program it in LabVIEW.

0 Kudos
Message 4 of 13
(4,476 Views)

nyc,

   I see what you're saying.  I've learned how to use ActiveX by basically taking the property and invoke nodes from other VI's I've found and making it work the way I need it to.  My problem is that I can't find the Excel Application Object Library which will give me the propty and invoke blocks I need.  Do you know what that file name is or what the library is called under the "Type Libaray"

 

LV3.JPG

0 Kudos
Message 5 of 13
(4,461 Views)

Try the Microsoft Excel object library; the version will vary depending on what version of Office you have installed. You probably want to open a reference to the Application object, then use invoke and property nodes from there to get a reference to a workbook.

0 Kudos
Message 6 of 13
(4,450 Views)
Solution
Accepted by topic author DrNO23

I found the solution.  If you can't find the Excel Object Library under the dropdown of all the installed object libraries its becuase apparently the Excel team does it differently and compiles the library into the EXCEL.exe file.  Just bring up the "Select Object from Type Library" window and then 'browse' and find the EXCEL.exe file.  It will incorporate it like the .OLB files

0 Kudos
Message 7 of 13
(4,443 Views)

@DrNO23 wrote:

I found the solution.  If you can't find the Excel Object Library under the dropdown of all the installed object libraries its becuase apparently the Excel team does it differently and compiles the library into the EXCEL.exe file.  Just bring up the "Select Object from Type Library" window and then 'browse' and find the EXCEL.exe file.  It will incorporate it like the .OLB files


Why don't you post a VI instead of talking about it?  It would so much more helpful.  I have no clue what you just wrote there in your explanation. Yes, call me clueless.

 

In addition, which version of Excel would be helpful as well.

 

 

0 Kudos
Message 8 of 13
(4,438 Views)

nyc,

   I just wanted to know how to get the block that I showed in the question, the "VBProject property of the Workbook I'm referencing", thats why I only showed the one block.

 

When working with ActiveX and Excel, you need a Library of the functions and properties which you can modify to manipulate the EXCEL sheet.  To get started you can first use a Reference to your library and then feed that into the Property and Invoke nodes which allow you to write the variables from LabVIEW.  My problem was that I couldn't find the location of the file to point my Automation Refnum control at.  If you wanted to mess around with Microsoft PowerPoint then you simply right click your Automation Refnum "Select ActiveX Class">>"Browse" and then scroll through the lists of Object Libraries and if you can't find it then you can select "Browse" on that window and search the Microsoft Office folders for MSPPT.olb, the file that will give you access to PowerPoint control through LabVIEW.  If you wanted to manipulate Excel files in LabVIEW you would need to find the EXCEL.exe executable through the Select Object window and voila you now have ActiveX control of EXCEL.

0 Kudos
Message 9 of 13
(4,417 Views)

@DrNO23 wrote:

nyc,

   I just wanted to know how to get the block that I showed in the question, the "VBProject property of the Workbook I'm referencing", thats why I only showed the one block.

 

When working with ActiveX and Excel, you need a Library of the functions and properties which you can modify to manipulate the EXCEL sheet.  To get started you can first use a Reference to your library and then feed that into the Property and Invoke nodes which allow you to write the variables from LabVIEW.  My problem was that I couldn't find the location of the file to point my Automation Refnum control at.  If you wanted to mess around with Microsoft PowerPoint then you simply right click your Automation Refnum "Select ActiveX Class">>"Browse" and then scroll through the lists of Object Libraries and if you can't find it then you can select "Browse" on that window and search the Microsoft Office folders for MSPPT.olb, the file that will give you access to PowerPoint control through LabVIEW.  If you wanted to manipulate Excel files in LabVIEW you would need to find the EXCEL.exe executable through the Select Object window and voila you now have ActiveX control of EXCEL.


 

I am familiar with Accessing an ActiveX-Enabled Application as outlined at http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/using_activex_with_labview/

 

I don't understand what YOU are doing. So I am simply asking for a VI.

 

 

0 Kudos
Message 10 of 13
(4,407 Views)