LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default style propertie causing excel not being released

the following procedure in visual studio 2005, works fine and the Excel
process can be released successfully, but when I try to use the Style
propertie (between doted lines below), it looks that some hidden object is
created which I'm not able to release:

Public sub SaveExcel(ByVal filePath As String)
Dim xl As Excel.Application
Dim wbs As Excel.Workbooks
Dim wb As Excel.Workbook
Dim sheets As Excel.Sheets
xl = New Excel.Application
wbs = xl.Workbooks
wb = wbs.Add()
sheets = wb.Worksheets
xl.Visible = False
Dim range As Excel.Range = xl.ActiveCell
sheets(1).Range("A1") = "Client code:"

'---------------------------------------------------------------------------
Dim labelStyle As Excel.Style
labelStyle = wb.Styles.Add("myStyle")
..... ...
... .
' ----------------------------------------------------------------------------

ReleaseComObject(labelStyle)
labelStyle = Nothing
xl.DisplayAlerts = False
wb.SaveAs(filePath, FileFormat:=Excel.XlFileFormat.xlExcel7)
ReleaseComObject(range)
Dim sheet As Excel.Worksheet
For Each sheet In sheets
ReleaseComObject(sheet)
Next
ReleaseComObject(sheets)
wb.Close(False)
xl.Quit()
ReleaseComObject(wb)
ReleaseComObject(wbs)
ReleaseComObject(xl)
End sub



Private Sub ReleaseComObject(ByRef Reference As Object)
Try
Do Until System.Runtime.InteropServices.Marshal.ReleaseComO bject(Reference)
<= 0
Loop
Catch
Finally
Reference = Nothing
End Try
End Sub


thanks for help.

 
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
Is Excel 2007 released ? Shirish New Users to Excel 2 April 6th 06 07:59 PM
when is the next microsoft office excel going to be released? Cyndi(KCMO) Excel Discussion (Misc queries) 2 March 17th 06 02:13 PM
From where i can get list of all released version number of Excel Dev Excel Discussion (Misc queries) 0 December 14th 05 09:19 AM
Excel 12 - Information Released Jim Cone Excel Programming 0 September 23rd 05 06:52 PM
excel not being released by vb.net Mike[_55_] Excel Programming 0 October 3rd 03 03:10 PM


All times are GMT +1. The time now is 07:14 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"