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.
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.
07-08-2014 11:20 AM
I justed started working with CVI and Excel and I am Using the Excel Report Library.
Basically, what I am doing is: I open existing Excel Templates, edit the docs and save and close it (see code below).
Currently I have a workbook handle for each workbook that I open, but I am using only 1 application handle for all the workbooks. It works so far but I am not sure whether I will run into troubles later.
1. Is it necessary to create multiple application handles for each workbook?
2. When talking about the "application", what does it refer to? The Excel Application? If yes, another application would be Word or another instance of Excel?
/*Declaration Handles*/ static CAObjHandle workbookHandle2; static CAObjHandle workbookHandle3; static CAObjHandle workbookHandle4; static CAObjHandle applicationHandle; /*Create new app*/ ExcelRpt_ApplicationNew(VTRUE,&applicationHandle); /*open existing wb*/ ExcelRpt_WorkbookOpen(applicationHandle,"C:\\testfile123.xltx", &workbookHandle2); ExcelRpt_WorkbookOpen(applicationHandle,"C:\\testfile123.xlt", &workbookHandle3); ExcelRpt_WorkbookOpen(applicationHandle,"C:\\testfile123.xltm", &workbookHandle4); /*save templates*/ ExcelRpt_WorkbookSave(workbookHandle2, "testfile2.xlsx", ExRConst_DefaultFileFormat); ExcelRpt_WorkbookSave(workbookHandle3, "testfile3.xlsx", ExRConst_DefaultFileFormat); ExcelRpt_WorkbookSave(workbookHandle4, "testfile4.xlsx", ExRConst_DefaultFileFormat);
Thanks,
ZerMahlMer
Solved! Go to Solution.
07-08-2014 04:00 PM
07-09-2014 04:48 PM
Thx man! That is just the confirmation I needed!
07-10-2014 12:24 AM
Good, I am glad you are good to go! 😉
I see I have conflicted with myself in the second paragraph of my post.
"The important point is, do not forget to discard your handles when you do not need them (after you close the Excel app)."
Corrected version:
You should discard your workbook/worksheet (not the application handle of course) handles before you quit Excel.
Otherwise Excel does not disappear from task manager even if it looks like it is terminated.