Thanks Herfried, but it doesn't resolve the problem
here is the whole code, can you please take a look to see what is wrong
Thanks.
Dim oExcel As Object
Dim oBook As Excel.Workbook
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
oSheet = oBook.Worksheets(1)
'Create the QueryTable object.
Dim oQryTable As Object
oQryTable = oSheet.QueryTables.Add(conString, oSheet.Range("A1"), sqlstring)
oQryTable.RefreshStyle = 2 ' xlInsertEntireRows = 2
oQryTable.Refresh(False)
'Save the workbook and quit Excel.
If Dir(fileName) <> "" Then Kill(fileName)
oBook.SaveAs(fileName)
oQryTable = Nothing
oSheet = Nothing
oBook.Close()
oBook = Nothing
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(oExcel)
oExcel = Nothing
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bn*************@ID-208219.news.uni-berlin.de...
* "touf" <to******@hotmail.com> scripsit: I've an error when I declare
Dim oBook As Excel.Workbooks
What imports, and reference do I need to use Excel.Workbooks class?
HOWTO: Automate Microsoft Excel from Visual Basic .NET
<http://support.microsoft.com/default.aspx?scid=kb;en-us;301982>
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bn*************@ID-208219.news.uni-berlin.de... * "touf" <to******@hotmail.com> scripsit: It creates an excel file and save it on the disc, but When I double-clic
on it (explorer) it open Excel and bloc,(don't display the data), it does
the same with all excel files.
I've found that it creates a process called Excel, when I end it
(Windows Task Manager) the problem is resolved.
I think that I need somewhere to kill the process..(I use oExcel.Quit()
but doesn't do the job)
Close all workbooks, then use:
\\\
objExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(objExcel)
objExcel = Nothing
///
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>