Solved

xl97: Access violation closing Excel

Posted on 1998-06-16
6
371 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now