Could not invoke member ActiveWorkbook

TimoBo
Member Posts: 31
Hi,
I have an Excel 2003 file with 3 worksheets. One worksheet contains a pivot table. When I try to open the file from Navision, I get the following error:
Could not invoke the member ActiveWorkbook.
The same function works fine with Excel files without pivot table.
Does anybody know more about this problem?
I have an Excel 2003 file with 3 worksheets. One worksheet contains a pivot table. When I try to open the file from Navision, I get the following error:
Could not invoke the member ActiveWorkbook.
Create(Excel); Excel.Workbooks.Open(FileName); ExcelWorkbook := Excel.ActiveWorkbook;
The same function works fine with Excel files without pivot table.
Does anybody know more about this problem?
0
Comments
-
You get that error because you open the workbook but it is not active, it's just open.
By first creating your autExcel object and then just adding the workbook straight from the file this error SHOULD not occur.
So try the following:
CREATE(autExcel);
autWorkBook.Close; //=> Always close any active open workbook
autWorkBook := autApplic.Workbooks.Add(ptxtFileName);
autWorkSheet := autWorkBook.ActiveSheet;
FYI: First Close any open workbook!
I wish you the best!0 -
Hi Timobo,
Today I encountered exactly the same problem. First thought that it was caused by a corrupted installation somehow but that was not the case. The problem is reproducable on other PC's of our company too. Another reason I thought of was the 64-bit OS (Windows 7). Tried it on Windows Server 2003 64 bit too. Everywhere the same error kept popping up.
When I entered the debugger and stepped through the code the code ran without any problem. But running it without debugger did not. Been almost busy whole day to solve this, but the good news is ... I found a solution/work around!
What I did was simply adding a SLEEP(100) statement between the last two lines.
Excel.Workbooks.Open(FileName);
SLEEP(100)
ExcelWorkbook := Excel.ActiveWorkbook;
For me it works. Apperently the OS must be given a short time to execute some background processing.
If somebody has a better solution it would be greatly appreciated when it was shared here.Theo van de Ven
Technical Consultant | System Administrator
Rainbow Crossmedia BV
Bosmanskamp 63
4191MT Geldermalsen0
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