Getting handle of opened Excel application

nilayinc

New member
Joined
Jul 31, 2003
Messages
1
Hello,

I want to update excel document with the helpp of .net. I am able to open an excel document and update it successfully. But if my excel document in already open then it opens in read only mode. Instead of opening in read only mode, I want to get handle of already open excel file. How can I get it?

Kindly let me know.

Thanks and Regards,
Nilay.
 
you could close it like this :
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myProcess As Process
        myProcess.GetProcesses(Environment.MachineName)
        For Each myProcess In myProcess.GetProcesses
            If myProcess.ProcessName = "EXCEL" Then
                myProcess.CloseMainWindow()
            End If
        Next
    End Sub
 
Instead of opening in read only mode, I want to get handle of already open excel file.

Even if you are able to get that "handle", I doubt if you could take over it since it belongs to another process; the only way to go about it is to forcibly shutdown the Excel instance that owns the open document. In VB6, there is a GetObject(<blank parameter>,"Excel.Application") function that will return a reference to the running instance of Excel, if one exists. This can be a viable alternative for you if dynamic_sysops reply doesnt work for you.
 
Back
Top