Example Code

Search an Excel Spreadsheet from LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This example demonstrates how to search in Excel through LabVIEW using ActiveX.

 

 

Description

Many applications in the Windows environment give access to some of their most basic functions to a centralized framework called ActiveX. This allows for cross program interaction in a simple fashion. Available functions include "Start" and "Stop" in such programs as Windows Media Player and document formatting in Microsoft Word and Excel. This example allows you to search a Microsoft Excel spreadsheet for a specified string from within LabVIEW. LabVIEW opens Excel and uses the Find function within Excel and then retrieves the results.

 

 

Requirements 

LabVIEW 2012 (or compatible)

Windows Excel

 

 

Steps to Implement or Execute Code

1. Downlaod the zipped folder "Search in Excel_LV2012_NI Verified"

2. Open the project and launch the VI "Search Excel_LV2012_NI Verified"

3. Choose the path of the Excel file
4. Enter the Sheet you want to search within
5. Enter the String to Find
6. Run the VI

 

 

Additional Information or References

Front Panel FP.PNG

Block Diagram

 BD.PNG

Notes

Please note the ActiveX interface is specific to Microsoft Excel, as a result there is limited documentation on using the interface.  All the documentation can be found from Microsoft on the MSDN.

 

  

**This document has been updated to meet the current required format for the NI Code Exchange.**

------
John.P | Certified LabVIEW Architect | NI Alliance Member

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
LambdaPS
Member
Member
on

Very nicely done example.

The Excel file must be closed or else an "unknown" error is returned.

Alexander756
Member
Member
on

Hi,
Can you help me? I have more than one result string and I want to find all address of cells where "String To Find" exist (like a button "Find All" in Excel)
Thanks

bharathchandran
Member
Member
on

Searching all pos for given string in excel.pngSearching and finding all position of a given string in an excel sheet. developed using labview 2012

iadalbash
Member
Member
on

Hello! anybody have the vi to find all position? can attach? i can't find how to add the invoke node for range.

JoerieHemerijckx
Member
Member
on

Hi,

Very nicely done.

I need to search only in row A how can i do this ?