473,394 Members | 1,693 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,394 software developers and data experts.

Excel 2003 Application Question

I am having some trouble manipulating Excel files. Currently I am
trying to create and then close an Excel file/application with the following
code. It works fine, except it leaves an EXCEL application open, which I can
see in the Task Manager. I have tried oExcel.Dispose(), but this generates
an error. How can I correct this code so that the object is properly
disposed of? Thanks!

Public Sub CreateExcelFile(Optional ByVal sFileName As String =
"")
If Len(sFileName) > 0 Then FileName = sFileName
If Not Len(FileName) > 0 Then
MsgBox("The 'FileName' property must be set before the
'CreateExcelFile' method may be utilized", , "ERROR")
Exit Sub
End If
oExcel = CreateObject("Excel.Application")
With oExcel
.SheetsInNewWorkbook = 1
oExcel = .Workbooks.Add
.Save(FileName)
.Quit()
End With
oExcel = Nothing
End Sub
Nov 20 '05 #1
5 2157
http://www.wizkil-webs.net/NET/DotNe...m#_Toc78169306

hope this helps

"Jason" <so*****@microsoft.com> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
I am having some trouble manipulating Excel files. Currently I am
trying to create and then close an Excel file/application with the following code. It works fine, except it leaves an EXCEL application open, which I can see in the Task Manager. I have tried oExcel.Dispose(), but this generates
an error. How can I correct this code so that the object is properly
disposed of? Thanks!

Public Sub CreateExcelFile(Optional ByVal sFileName As String =
"")
If Len(sFileName) > 0 Then FileName = sFileName
If Not Len(FileName) > 0 Then
MsgBox("The 'FileName' property must be set before the
'CreateExcelFile' method may be utilized", , "ERROR")
Exit Sub
End If
oExcel = CreateObject("Excel.Application")
With oExcel
.SheetsInNewWorkbook = 1
oExcel = .Workbooks.Add
.Save(FileName)
.Quit()
End With
oExcel = Nothing
End Sub

Nov 20 '05 #2
It does help, thanks. However, I see that they are referencing the Excel
object model explicitly (i.e., they added a reference to their project or
solution via VisualStudio), whereas I am late-binding. I'm only doing this
because when I tried to add a reference I couldn't find Excel available as a
..Net reference (I added one called "office" but it doesn't seem to have any
available functions or properties). Any idea how I can get ahold of (and
register, I suppose) the reference?

"BrianDH" <No**********@nospam.com> wrote in message
news:da********************@telcove.net...
http://www.wizkil-webs.net/NET/DotNe...m#_Toc78169306

hope this helps

"Jason" <so*****@microsoft.com> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
I am having some trouble manipulating Excel files. Currently I am
trying to create and then close an Excel file/application with the

following
code. It works fine, except it leaves an EXCEL application open, which I

can
see in the Task Manager. I have tried oExcel.Dispose(), but this generates an error. How can I correct this code so that the object is properly
disposed of? Thanks!

Public Sub CreateExcelFile(Optional ByVal sFileName As String = "")
If Len(sFileName) > 0 Then FileName = sFileName
If Not Len(FileName) > 0 Then
MsgBox("The 'FileName' property must be set before the
'CreateExcelFile' method may be utilized", , "ERROR")
Exit Sub
End If
oExcel = CreateObject("Excel.Application")
With oExcel
.SheetsInNewWorkbook = 1
oExcel = .Workbooks.Add
.Save(FileName)
.Quit()
End With
oExcel = Nothing
End Sub


Nov 20 '05 #3
OK
Under the COM Refference
I am using:
Microsoft Excel 9.0 Object Library - Excel.dll
Microsoft Office 9.0 Object Library - Office.dll
Imports system IO

B

"Jason" <so*****@microsoft.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
It does help, thanks. However, I see that they are referencing the Excel
object model explicitly (i.e., they added a reference to their project or
solution via VisualStudio), whereas I am late-binding. I'm only doing this
because when I tried to add a reference I couldn't find Excel available as a .Net reference (I added one called "office" but it doesn't seem to have any available functions or properties). Any idea how I can get ahold of (and
register, I suppose) the reference?

"BrianDH" <No**********@nospam.com> wrote in message
news:da********************@telcove.net...
http://www.wizkil-webs.net/NET/DotNe...m#_Toc78169306

hope this helps

"Jason" <so*****@microsoft.com> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
I am having some trouble manipulating Excel files. Currently I am trying to create and then close an Excel file/application with the following
code. It works fine, except it leaves an EXCEL application open, which I
can
see in the Task Manager. I have tried oExcel.Dispose(), but this generates an error. How can I correct this code so that the object is properly
disposed of? Thanks!

Public Sub CreateExcelFile(Optional ByVal sFileName As
String = "")
If Len(sFileName) > 0 Then FileName = sFileName
If Not Len(FileName) > 0 Then
MsgBox("The 'FileName' property must be set before

the 'CreateExcelFile' method may be utilized", , "ERROR")
Exit Sub
End If
oExcel = CreateObject("Excel.Application")
With oExcel
.SheetsInNewWorkbook = 1
oExcel = .Workbooks.Add
.Save(FileName)
.Quit()
End With
oExcel = Nothing
End Sub



Nov 20 '05 #4
Not 100% on this, but I think you need the PIA for Excel 2003.

http://msdn.microsoft.com/library/de...assemblies.asp

Greg

"Jason" <so*****@microsoft.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
It does help, thanks. However, I see that they are referencing the Excel
object model explicitly (i.e., they added a reference to their project or
solution via VisualStudio), whereas I am late-binding. I'm only doing this
because when I tried to add a reference I couldn't find Excel available as a .Net reference (I added one called "office" but it doesn't seem to have any available functions or properties). Any idea how I can get ahold of (and
register, I suppose) the reference?

"BrianDH" <No**********@nospam.com> wrote in message
news:da********************@telcove.net...
http://www.wizkil-webs.net/NET/DotNe...m#_Toc78169306

hope this helps

"Jason" <so*****@microsoft.com> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
I am having some trouble manipulating Excel files. Currently I am trying to create and then close an Excel file/application with the following
code. It works fine, except it leaves an EXCEL application open, which I
can
see in the Task Manager. I have tried oExcel.Dispose(), but this generates an error. How can I correct this code so that the object is properly
disposed of? Thanks!

Public Sub CreateExcelFile(Optional ByVal sFileName As
String = "")
If Len(sFileName) > 0 Then FileName = sFileName
If Not Len(FileName) > 0 Then
MsgBox("The 'FileName' property must be set before

the 'CreateExcelFile' method may be utilized", , "ERROR")
Exit Sub
End If
oExcel = CreateObject("Excel.Application")
With oExcel
.SheetsInNewWorkbook = 1
oExcel = .Workbooks.Add
.Save(FileName)
.Quit()
End With
oExcel = Nothing
End Sub



Nov 20 '05 #5
Hi
Use the following code to close the excel aplication

System.Runtime.InteropServices.Marshal.ReleaseComO bject
(xlApp)
xlapp = nothing

Kind Regards
Jorge
-----Original Message-----
I am having some trouble manipulating Excel files. Currently I amtrying to create and then close an Excel file/application with the followingcode. It works fine, except it leaves an EXCEL application open, which I cansee in the Task Manager. I have tried oExcel.Dispose(), but this generatesan error. How can I correct this code so that the object is properlydisposed of? Thanks!

Public Sub CreateExcelFile(Optional ByVal sFileName As String ="")
If Len(sFileName) > 0 Then FileName = sFileName If Not Len(FileName) > 0 Then
MsgBox("The 'FileName' property must be set before the'CreateExcelFile' method may be utilized", , "ERROR")
Exit Sub
End If
oExcel = CreateObject("Excel.Application")
With oExcel
.SheetsInNewWorkbook = 1
oExcel = .Workbooks.Add
.Save(FileName)
.Quit()
End With
oExcel = Nothing
End Sub
.

Nov 20 '05 #6

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

Similar topics

6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
3
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
6
by: Gunawan | last post by:
Dear All, I have create an excel (COM Object) using this code Excel.Application xls = new Excel.Application(); but I can not remove it from memory although I have using close and quit ...
4
by: snare88 | last post by:
I have a question regarding a VB.NET 2003 application which was built on a Windows XP machine with Office 2002 installed. The software does some interfacing with Microsoft Excel. I now want to...
3
by: rlntemp-gng | last post by:
RE: Access 2003/Excel 2003 Problem: After I close the Access application completely, I go out to the Task Manager and there is an Excel.exe object still sitting out there. My Access...
0
by: Bill Fallon | last post by:
I am developing a VB.Net application with VS 2005 that opens an Excel workbook and populates the worksheet with data. I started developing the application with Office 2007 installed on my Vista...
8
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. The data opens up correctly in MS office Excel 2007 but when we use a mahcine with MS Office 2003 we encountered a message, "Cannot read output file" Is...
4
by: =?Utf-8?B?THluZXJz?= | last post by:
Hello All, We have a VB.NET application writen using VS 2003. This application apens an excel file from a vendor, reads the data and performs whatever functions it needs. We recently upgraded our...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.