Solved

xl97: Access violation closing Excel

Posted on 1998-06-16
6
382 Views
Last Modified: 2011-10-03
I have a VB4 appl. that creates an excel spreadsheet and dumps data to it. (NT4) When I shut down Excel ('close the workbook), I get Dr. Watson:

                        EXCEL.exe
Exception: access violation(0xc0000005),Address:0x3002db7

I'm using CreateObject to create my workbook and have tried
the combinations of setting the workbook/worksheet objects to nothing in my appl. to no avail.

dim xltemp, rptexcel as object

 Set xltemp = CreateObject("Excel.sheet") 'Create OLE object
 Set rptExcel = xltemp.ActiveSheet

'set xltemp = nothing
'set rptexcel = nothing

I've read the microsoft support doc. q176242, but am not
convinced that's whats happening here.

Any help you can give would be appreciated.
thanks.
0
Comment
Question by:BOSS
6 Comments
 
LVL 1

Expert Comment

by:Sekans
ID: 1463480
BOSS, try using:
Set xltemp = CreateObject("Excel.Application")' create the application instead of just the sheet
xltemp.Quit

then
Set xltemp = Nothing
Set rptexcel = Nothing

Regards,
Sekans
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463481
Just curious...
Do you have the worksheet open in Excel at the same time you are accessing it from within VB?
0
 
LVL 4

Expert Comment

by:zsi
ID: 1463482
On an unrelated side note, you do realize that the following line:

      dim xltemp, rptexcel as object

is the same as this:

     Dim xltemp as Variant
     Dim rptexecl as Object

Not that this will have any bearing on what you are doing.  I just thought that I would point it out.

zsi
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BOSS
ID: 1463483
Tried the create "excel.application" route and .quit functionality also to no avail. Therefore this is still a problem
with or without excel open.  
0
 
LVL 1

Expert Comment

by:Sekans
ID: 1463484
Can you open the sheet into excel using just excel.  Just a thought, but you may want to be sure it is not a problem with excel.

Sekans
0
 

Accepted Solution

by:
gsmotherman earned 150 total points
ID: 1463485
Dim xl as Object
'or Dim xl As Excel.Application

Set xl = CreateObject("Excel.Application")

'Do stuff

xl.ActiveWorkbook.Close 'False
xl.Quit 'False
Set xl = Nothing

Try this,
Gary

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question