Solved

xl97: Access violation closing Excel

Posted on 1998-06-16
6
388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

707 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