Solved

xl97: Access violation closing Excel

Posted on 1998-06-16
6
376 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

785 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