Excel 2003 Automation error

bt2003
Member Posts: 9
Hi
I am trying to create, populate and the save an excel file through the use of automation only. This is to happen without excel being visible to the user.
Navision is UK 4.00 sp3
Excel is from office 2003
Automation is Microsoft Excel 11.0 Object Library
I can create an excel worksheet successfully. The code to save it causes the error
"This message is for C/AL programmers: Could not invoke the member SaveAs. The OLE control or Automation returned the following message: The requested member does not exist, or the call tried to set the value of a read-only property."
Main bits of code for this issue are :
Global Vars:
MSExcel Automation 'Microsoft Excel 11.0 Object Library'.Application
XLBook Automation 'Microsoft Excel 11.0 Object Library'.Workbook
XLSheet Automation 'Microsoft Excel 11.0 Object Library'.Worksheet
CLEAR(MSExcel);
CREATE(MSExcel);
MSExcel.Visible(FALSE);
XLBook := MSExcel.Workbooks.Add;
XLSheet := XLBook.ActiveSheet;
XLSheet.Name := 'First Sheet';
XLBook.SaveAs('C:\test.xls');
It is the last line that generates the error. I have tried replacing the final line with XLSheet.SaveAs('C:\test.xls'), but get the same error.
Any help would be greatly appreciated.
I am trying to create, populate and the save an excel file through the use of automation only. This is to happen without excel being visible to the user.
Navision is UK 4.00 sp3
Excel is from office 2003
Automation is Microsoft Excel 11.0 Object Library
I can create an excel worksheet successfully. The code to save it causes the error
"This message is for C/AL programmers: Could not invoke the member SaveAs. The OLE control or Automation returned the following message: The requested member does not exist, or the call tried to set the value of a read-only property."
Main bits of code for this issue are :
Global Vars:
MSExcel Automation 'Microsoft Excel 11.0 Object Library'.Application
XLBook Automation 'Microsoft Excel 11.0 Object Library'.Workbook
XLSheet Automation 'Microsoft Excel 11.0 Object Library'.Worksheet
CLEAR(MSExcel);
CREATE(MSExcel);
MSExcel.Visible(FALSE);
XLBook := MSExcel.Workbooks.Add;
XLSheet := XLBook.ActiveSheet;
XLSheet.Name := 'First Sheet';
XLBook.SaveAs('C:\test.xls');
It is the last line that generates the error. I have tried replacing the final line with XLSheet.SaveAs('C:\test.xls'), but get the same error.
Any help would be greatly appreciated.
0
Answers
-
Although you are creating your own automation, you should check out this handy excel tool
This is a code extract from that tool:IF NOT EXISTS(WorkBookPath) THEN XlBook.SaveAs(WorkBookPath) ELSE XlBook.Save; XlBook.Close(FALSE); CLEAR(XlSheet); XlApp.Quit; CLEAR(XlApp);
WorkbookPath is text [250] (which in your case would be 'C:\test.xls')0 -
Thanks for the reply sog. Have tried it, but get the same result.
I am now beginning to suspect the my installation of office 2003.0 -
You should check if you have the rights to save a file at that location (in this case the C-drive)0
-
Can you try assigning the filename to a saveFileName text variable and doing:
saveFileName := 'c:\123.docx'; wDoc.SaveAs(saveFileName);
I had the same problem with Word automation and it worked...0 -
I have carried out a repair on my office 2003, and it now works. Great!
Thanks for the prompt replies.
I think the problem arose because I also had just excel 2000 installed (after office 2003).0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions