Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

xl97: Access violation closing Excel

Posted on 1998-06-16
6
Medium Priority
?
399 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
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 300 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

610 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