ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   workbook and application reference set to null after the user enters something in an excel sheet (https://www.excelbanter.com/excel-programming/298832-workbook-application-reference-set-null-after-user-enters-something-excel-sheet.html)

Tobias[_3_]

workbook and application reference set to null after the user enters something in an excel sheet
 
Hello All,

I've got the following problem: I'm trying to control an Excel
Application using ActiveX (out of Agilent-Vee).
I create the application, open an Excel file and make it visible. The
user is supposed to enter data in the sheet and after that has to push
a button (its a vee button) and the workbook is saved (out of vee). It
works perfect as long as the user doesn't enter any data. As soon as
he does the references to my workbook and application are set to Null
and I'm not able to save it anymore. I get the message "SaveAs" is not
a member of the referenced ActiveX object (which will bee the
reference to the workbook).

The code (entered in Vee Formulars, but i think i doesn't matter):

set ExcelApp=Createbject("Excel.Application");
ExcelApp.Visible=True;
ExcelApp.Workbooks.Open(filename);
set ExcelBook=ExcelApp.ActiveWorkbook;

then I call the "save" button

if the button is pressed:

ExcelApp.SaveAs(filename);
ExcelBook.Close();
ExcelApp.Quit();

ExcelApp and ExcelBook are global variables.

I hope somebody can help me here - thank you very much.

Tobias


All times are GMT +1. The time now is 09:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com