473,378 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Automation - Excel & Access

Hi,
I'm currently building a function in Access that creates an Excel
spreadsheet but it doesn't look like the Excel object is being
destroyed correctly as the Excel module is still showing in the task
manager and I'm unable to open the spreadsheet without first closing
down Access. Can anyone help!?

Dave

Public Function CreateInputSheet(scriptName As String, ParamArray
aFields() As Variant) As Boolean

Dim objExcel As New Excel.Application

' *** Code Snipped ***

objExcel.ActiveWorkbook.SaveAs "c:\data\myexceltest1.xls"
objExcel.ActiveWorkbook.Close
objExcel.Quit
Set objExcel = Nothing
End Function

Nov 13 '05 #1
1 3572
I find that using the "Active" references in EXCEL automation often leads to
the creation of additional objects in EXCEL that are not closed when you try
to quit EXCEL. Use explicit references to Workbook and Worksheet objects,
etc.
Public Function CreateInputSheet(scriptName As String, ParamArray
aFields() As Variant) As Boolean

Dim objExcel As New Excel.Application

' *** Code Snipped ***

objExcel.Workbook(1).SaveAs "c:\data\myexceltest1.xls"
objExcel.Workbook(1).Close
objExcel.Quit
Set objExcel = Nothing
End Function

Or use an object to create the new workbook:

Dim objWBook As Object
..
..
..
Set objWBook = objExcel.Workbooks.Add
..
..
objWBook.SaveAs "c:\data\myexceltest1.xls"
objWBook.Close
Set objWBook = Nothing
objExcel.Quit
Set objExcel = Nothing

--

Ken Snell
<MS ACCESS MVP>
<u7***@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,
I'm currently building a function in Access that creates an Excel
spreadsheet but it doesn't look like the Excel object is being
destroyed correctly as the Excel module is still showing in the task
manager and I'm unable to open the spreadsheet without first closing
down Access. Can anyone help!?

Dave

Public Function CreateInputSheet(scriptName As String, ParamArray
aFields() As Variant) As Boolean

Dim objExcel As New Excel.Application

' *** Code Snipped ***

objExcel.ActiveWorkbook.SaveAs "c:\data\myexceltest1.xls"
objExcel.ActiveWorkbook.Close
objExcel.Quit
Set objExcel = Nothing
End Function

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my...
12
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000...
1
by: Jimmer | last post by:
I've got what should be an easy automation problem, but the solution simply isn't coming to me. I've got several public variables set up for automation as follows: Public gappExcel As...
5
by: Gary Cobden | last post by:
I have a problem with the following code, which leaves an instance of Excel visible in Task Manager. By a process of elimination I have got it down to the fact that something in the...
7
by: taylor.bryant | last post by:
I am running: Win XP SP2 Excel 2002, Access 2002 (Office XP SP3) Using Visual Basic (not VB.NET) At one point (prior to XP SP2?!? - I can't pin it down), this did not happen and I was easily...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
2
by: Alfredo Magallón Arbizu | last post by:
Hello, I have an ASP.NET application that reads an Excel file through automation. The app has a loop until first cell of a row is blank. While the app works perfectly under Windows 2003, it...
4
by: Keith Wilby | last post by:
How controllable from Access VBA is Excel? I'm currently using automation to dump 2 columns of data into an Excel spreadsheet so that the end user can create a line graph based on it. Could the...
4
by: Belgarath | last post by:
Hello all, I'm a newbie in Access... And before starting to explore this software, I would like to know if it's possible to automate everyday queries result in Excel . If it's possible can...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.