473,796 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find the process id of excel application in ASP.Net

Sri
I am writing an asp.net applicaition using VB coding.

In a function, I am opening an excel file with the following code,
Dim objExcel As Object
Dim objWorkBook As Object
objExcel = CreateObject("E xcel.Applicatio n")
objWorkBook = objExcel.Workbo oks.Open(target filename)
* targetfilename is a variable that stores the excel file name and path.

In the error handler,

I want to kill only the excel application created using previous line of
code. There can be any other excel application running in the server that
were not created by this application. How will I identify the process ID of
this excel application through code and kill the process.

Jul 22 '05 #1
2 10699
On Thu, 30 Jun 2005 03:56:01 -0700, Sri <Sr*@discussion s.microsoft.com > wrote:

¤ I am writing an asp.net applicaition using VB coding.
¤
¤ In a function, I am opening an excel file with the following code,
¤ Dim objExcel As Object
¤ Dim objWorkBook As Object
¤ objExcel = CreateObject("E xcel.Applicatio n")
¤ objWorkBook = objExcel.Workbo oks.Open(target filename)
¤ * targetfilename is a variable that stores the excel file name and path.
¤
¤ In the error handler,
¤
¤ I want to kill only the excel application created using previous line of
¤ code. There can be any other excel application running in the server that
¤ were not created by this application. How will I identify the process ID of
¤ this excel application through code and kill the process.

You could use the FindWindow API function call
(http://msdn.microsoft.com/library/de...findwindow.asp)

Declare Function FindWindow Lib "user32" Alias "FindWindow A" (ByVal lpClassName As String, ByVal
lpWindowName As String) As Int32
Declare Function PostMessage Lib "user32" Alias "PostMessag eA" (ByVal hwnd As Int32, ByVal wMsg
As Int32, _
ByVal wParam As Int32, ByVal
lParam As Int32) As Int32

Public Function TerminateExcel( )

Dim ClassName As String
Dim WindowHandle As Int32
Dim ReturnVal As Int32
Const WM_QUIT = &H12

Do

ClassName = "XLMain"
WindowHandle = FindWindow(Clas sName, Nothing)

If WindowHandle Then
ReturnVal = PostMessage(Win dowHandle, WM_QUIT, 0, 0)
End If

Loop Until WindowHandle = 0

End Function
Paul
~~~~
Microsoft MVP (Visual Basic)
Jul 22 '05 #2
Sri
Thank you. I have one more issue in context to this same kill process
I have a excel report generated in asp.net.
I create a temporary excel file in the server and the report is generated in
the temproray file. The file is created only through asp.net code and can
never be opened manually in the microsoft excel application since security
rights doesn't allow the user to view the path.

The code,
If File.Exists(tar getfilename) Then File.Delete(tar getfilename)

throws exception some times, if the file is used by some other process.
The reason could be due to some error created when the report was prevuiosly
executed.

The I open the taskmanager, goto process, select Image name excel.exe ,
Image name as asp.net and click end process. Thus the line of code executes
after this.

Please let me know how I can do this in asp.net

Your advice will greatly help me to program better.
------

"Sri" wrote:
I am writing an asp.net applicaition using VB coding.

In a function, I am opening an excel file with the following code,
Dim objExcel As Object
Dim objWorkBook As Object
objExcel = CreateObject("E xcel.Applicatio n")
objWorkBook = objExcel.Workbo oks.Open(target filename)
* targetfilename is a variable that stores the excel file name and path.

In the error handler,

I want to kill only the excel application created using previous line of
code. There can be any other excel application running in the server that
were not created by this application. How will I identify the process ID of
this excel application through code and kill the process.

Jul 22 '05 #3

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

Similar topics

4
21211
by: federico | last post by:
When I close an excel application opened from a python program with .Close() methood , in tasks manager is still present 'excel.exe' process and if I open manually an excel applicaion I have a transparent excel window... my os is win 2000 pro... Which is the right way to close an excel applicatio from python? Thanks
5
9374
by: KC | last post by:
Hi, I have code similar to this.. Dim xlApp As Object xlApp = CreateObject("Excel.Application", "\\MyServer") The call is from a asp.net (Intranet) application. \\Myserver is a network computer in the same domain as web server. The only way I can get this call worked is when I add the user who logs on to the web site as Administrators. I need to get this working without having to make the user administrator. Any suggestion?
8
25985
by: ChrisBowringGG | last post by:
When you use Application.Quit() on an Excel application, there can still be an instance of Excel running, as seen in Task Manager. You can try following the advice on MSDN: http://support.microsoft.com/kb/Q317109 but this didn't solve the problem for me.
1
3042
by: Bernd Muent | last post by:
Hi together, I am using the following code in Visual Basic to open Word or Excel applications: Word: Dim w As Word.Application w = CType(CreateObject("Word.application"), Word.Application) w.Application.Documents.Open("test.doc") With w.Application.Selection
2
323
by: Sri | last post by:
I am writing an asp.net applicaition using VB coding. In a function, I am opening an excel file with the following code, Dim objExcel As Object Dim objWorkBook As Object objExcel = CreateObject("Excel.Application") objWorkBook = objExcel.Workbooks.Open(targetfilename) * targetfilename is a variable that stores the excel file name and path. In the error handler,
1
1947
by: myname | last post by:
Hello, in VB.Net, I use Excel to display results : dim xl as new Excel.Application // creates an Excel process // snip (putting values into cells) xl.Visible = true If the user closes the Excel file, the Excel process remains in memory until my program is closed, which is good.
9
4551
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso TypeOf obj Is IDisposable Then DirectCast(obj, IDisposable).Dispose()
2
2415
by: =?Utf-8?B?TEJU?= | last post by:
Good Day, I have a web application created using ASP.NET (with VB.NET). The application allow user to browse Excel raw data file then the program will grab data from the file to perform further data processing. The question is I'm doing this by creating an Excel application everytime to do the processing which in other words ActiveX object is being created. New release of IE is blocking the ActiveX object which causes my application...
1
6986
by: raul15791 | last post by:
Hi, I'm new to C#. I'm writing a program that open a new excel file, write into it and lastly close the file. But the program is that there will be a orphaned process named EXCEL.EXE left on the process queue whenever the program quit. Anyway to terminate it automatically when the application exit? I read some previous postings on the same problem and try to use Marshal.ReleaseCOMObject and Garbage Collection. None of these works. Here's my...
0
10453
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.