Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VB.Net: Create Excel File/App?

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VB.Net: Create Excel File/App?

Look at this

Office Application Does Not Quit After Automation from Visual Studio .NET
Client
http://support.microsoft.com/default...B;en-us;317109

Michael Tomasura
"Jason" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VB.Net: Create Excel File/App?

Perfect! Thanks.

"Michael Tomasura" wrote in message
...
Look at this

Office Application Does Not Quit After Automation from Visual Studio .NET
Client
http://support.microsoft.com/default...B;en-us;317109

Michael Tomasura
"Jason" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a flat file in Excel GF08 Excel Discussion (Misc queries) 4 November 19th 09 05:10 PM
Can I use Excel to create this text file? BigIan Excel Worksheet Functions 4 September 15th 05 03:06 PM
How do i create an excel file using asp Farooq Excel Discussion (Misc queries) 0 March 15th 05 11:09 AM
Can you create an administrator for an excel file that is not sub. Katie Excel Worksheet Functions 1 November 2nd 04 07:17 PM
Create a xls File on Server without Excel? Milosz Excel Programming 1 June 21st 04 10:53 AM


All times are GMT +1. The time now is 08:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"