Example Code

Search an Excel Spreadsheet from LabVIEW

产品和环境

本部分要求填写创建该范例所需的产品和操作系统。

如要下载NI软件(包括以下所示产品),请访问ni.com/downloads

    软件

  • LabVIEW

代码和文档

添加附件

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

NI社区“代码范例交流区”(Example Code Exchange)中的代码范例已获得MIT许可

评论
LambdaPS
Member
Member
修改时间

Very nicely done example.

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

Alexander756
Member
Member
修改时间

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
修改时间

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
修改时间

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
修改时间

Hi,

Very nicely done.

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