By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,833 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,833 IT Pros & Developers. It's quick & easy.

kill a process by code?

P: n/a
Hi,
I use the folowing code to create a new Excel file using a query
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)

Any help please.

Dim oExcel As Object

Dim oBook As Object

Dim oSheet As Object

oExcel = CreateObject("Excel.Application")

oBook = oExcel.Workbooks.Add

oSheet = oBook.Worksheets(1)

.....

.... code......

.....

oBook.SaveAs(fileName)

oQryTable = Nothing

oSheet = Nothing

oBook = Nothing

oExcel.Quit()

oExcel = Nothing

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 create a process called Excel, when I end it the problem
is resolved.

Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* "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>
Nov 20 '05 #2

P: n/a
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>

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.