LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel_WorkbookClose in excel2000.fp generates unwanted "Save As" prompt.

 

Hi,

 

I created a LabWindows/CVI application that is developed and built on:
Windows XP Pro SP3
Labwindows/CVI 2009 Version 9.1.1
Microsoft Excel 2000

 

The application generates a report using excel2000.fp activex functions.
We've been running successfully for over a year until yesterday when I installed the application

on another computer running Windows7 and Excel2010.

 

On the new Win7 computer the report is created correctly.
The problem shows up when the application tries to save the workbook:


The "Save As" dialog box pops up and prompts the operator to verify the file name and location.
This does not happen on the computer that I'm developing on.
It also runs installs and runs OK on WinXP Pro and Excel2003.

 

The function call that causes the "Save As" to pop up is:
        autoError = Excel_WorkbookClose ( ExcelWorkbookHandleReport, NULL, CA_VariantBool (VTRUE), CA_DEFAULT_VAL, CA_VariantBool (VFALSE) );


It's a real problem because the program can no longer run un-attended.

 

Any ideas on how to work around this?

 

Kirk

 

0 Kudos
Message 1 of 5
(3,224 Views)

HI ,

 

I use the ExcelRpt_WorkbookClose();

 

there you can set the option for not showing the save as... panel

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 2 of 5
(3,217 Views)

 

It looks like the ExcelRpt_WorkbookClose(...) function gives you the option of whether you do, or do not want to save the file.

 

I do need to save the file, I just don't want it to prompt the operator.

 

Another thing I'm wondering about:

I'm using the excel2000.fp functions in my application.

I'm not sure if I can call functions from excelreport.fp using handles I've obtained using the excel2000.fp calls???

 

Kirk

 

0 Kudos
Message 3 of 5
(3,191 Views)

Hi kirkm,

 

If you want to use the ExcelRpt functionality, you should be able to change your original declaration to ExcelRpt_ApplicationNew() rather than Excel_NewApp() (http://forums.ni.com/t5/LabWindows-CVI/what-is-Difference-between-excel200-fp-amp-excelreport-fp/m-p...).

 

Have you tried explicitly saving with a save function and then just closing without asking to save? It’s not unheard of to get slightly different behavior when switching to a newer OS. This would be the next option that I would try instead of testing out different functions.  

 

You could also try using the ExcelRpt_WorkbookClose() function that Kobi was talking about and try that out if you construct a ExcelRpt instead of Excel.

The ExcelRpt functions are documented here (http://zone.ni.com/reference/en-XX/help/370051T-01/TOC388.htm)

 

Regards,

 

Michael Miracle

NI Americas | AE

0 Kudos
Message 4 of 5
(3,173 Views)

Hi Michael,

 

I'm trying not to switch to ExcelRpt because I have quite a lot of code that is opening several different .CSV files and pasting/ manimpulating the data into the final report.  It would be a lot of re-work.

 

I did try Excel_WorkbookSave(...).  It works on the Win XP system but returns an exception on the Win7 system.  Not sure why.

 

After much experimenting I found a solution that works on both XP and Win7:

 

First, after Excel_NewApp(...) I use a call to

 

 Excel_SetProperty ( ExcelAppHandle,              // CAObjHandle Object_Handle,
                                NULL,                             // ERRORINFO *Error_Info,
                                Excel_AppDisplayAlerts,  // unsigned int Property_ID,
                                CAVT_BOOL,                 // unsigned int Property_Type,
                                VFALSE                        // ...
                              );

This disables the prompting during the save.

 

Then when it comes time to save the file I use:

 

Excel_WorkbookSaveAs ( ExcelWorkbookHandleReport,  // CAObjHandle objectHandle,
                                       NULL,                                    // ERRORINFO *errorInfo,
                                       FileNameV,                            // VARIANT filename,
                                       CA_DEFAULT_VAL,               // VARIANT fileFormat,
                                       CA_DEFAULT_VAL,               // VARIANT password,
                                       CA_DEFAULT_VAL,               // VARIANT writeResPassword,
                                       CA_DEFAULT_VAL,               // VARIANT readOnlyRecommended,
                                       CA_DEFAULT_VAL,               // VARIANT createBackup,
                                       ExcelConst_xlNoChange,        // enum ExcelEnum_XlSaveAsAccessMode accessMode,
                                       CA_DEFAULT_VAL,               // VARIANT conflictResolution,
                                       CA_DEFAULT_VAL,               // VARIANT addToMru,
                                       CA_DEFAULT_VAL,               // VARIANT textCodepage,
                                       CA_DEFAULT_VAL                // VARIANT textVisualLayout
                                     );

 

This is followed by a call to Excel_WorkbookClose(...) with the save arugument set to False.  (previously I had set the save to True.)

 

Kind of frustrating that I don't understand WHY it doesn't the old way.  But at least I have a solution.

Maybe I should just be grateful that it continues to function (mostly) from Excel2000 all the way up to Excel2010 🙂 

 

Also, the excel2000.fp documentation is tough to deal with.  Right-clicking a function panel displays the message: "Could not launch VBAXL9.CHM"

I was able to find the VBAXL9.CHM help-file which is written for Visual Basic but you can mostly figure out what you need.

 

Thanks,

Kirk

 

 

 

 

 

 

 

 

Message 5 of 5
(3,162 Views)