LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Excel Workbook file Name ( *.xls )

I am using "excel2000.fp" from cvi installation samples.

my Question is :
1. how can i know the file name of a workbook that was already open, ( i don't have the workbook handle ).

2. how can I connect to Workbook that was already open
and get handle to it.
0 Kudos
Message 1 of 2
(2,879 Views)
If you have the handle to the application, you can get the collection of Workbooks and loop through the list and look for the right workbook by the name. Something like:


//Get the Workbooks collection from Application
Excel_GetProperty (hExcelApp, NULL, Excel_AppWorkbooks, CAVT_OBJHANDLE, &hWorkbooks);

//Get the number of Workbooks open
Excel_GetProperty (hWorkbooks, NULL, Excel_WorkbooksCount, CAVT_LONG, &numWorkbooks);

//Loop through WorkBooks and check name.
for(i=1;i<=numWorkbooks;i++)
{
Excel_WorkbooksItem (hWorkbooks, NULL, CA_VariantInt(i), hCurrentWorkbook);
Excel_GetProperty (hCurrentWorkbook, NULL, Excel_WorkbookName, CAVT_CSTRING, WorkbookName);

//Check name to see if it's the right Workbook.
...
}


Hope that hel
ps,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 2
(2,879 Views)