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

WebBrowser - Excel processs till running

P: n/a
Hi

recently read a posting and reply about Excel processs still running after
the Appliction.Quit was called. Thought I might be able to use the same
(System.Runtime.InteropServices.Marshal.ReleaseCom Object(exApplication)) to
solve my problem but could not.

Background :
My app uses a WebBrowser control to display to the user the contents of an
Excel spreadsheet.:

Dim oDocument As Object
Dim sName As String = "thefile.xls"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.Navigate(sName)
End If

Private Sub AxWebBrowser2_NavigateComplete2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Even t)
oDocument = e.pDisp.Document
End Sub

Every fifteen minutes another app obtains (via FTP) a raw "csv" file from an
external source, manipulates the file in various ways and saves the new file
to "thefile.xls"

The problem
The FTP process cannot save "thefile.xls" in the event that it is open in
the WebBrowser control of a user who is viewing the file

Attempted fixes.
FileSystemWatcher event looks for arrival of the FTP'd file and clears the
content of the WebBrowser control. Not successful since the Excel process is
still running and the Process is still holding the "thefile.xls" file open
although the WebBrowser may have navigated away from the file. The only way
to clear the Browser is to "kill" the Excel process. I could do that by
looping through each running instance of the process name "excel" and killing
it.....but that's a sledge hammer to crack a nut....I only need to close the
process that is being used by the WebBrwoser control. Since I'm not accessing
Excel as an Interop Com object I can't close it that way.

Does anyone have any suggestions. Is there a way to open the Excel document
in the WebBrowser as "read only" so the other external app can continue to
use it. Or a way to dispose of Excel after the WebBrowser navigates away from
the Excel document

Ay help or pointers would be appreciated.

Regards

Michael Bond
Sep 21 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
>
Does anyone have any suggestions. Is there a way to open the Excel
document
in the WebBrowser as "read only" so the other external app can continue to
use it. Or a way to dispose of Excel after the WebBrowser navigates away
from
the Excel document

Ay help or pointers would be appreciated.

Although I'm not sure on the specifics of your application (most often
failure to "dispose" is caused by not releasing COM references; but as you
say you aren't using InterOp), you could make a copy of the file locally if
it's just going to be readonly - then refresh it if you detect a change in
the original source file (by checking the modified time)?
Sep 21 '06 #2

P: n/a
Hi

hmmmm....I can see where you're going with this but the problem would still
exist. It would now be the copy that would be open in the WebBrowser and I'd
not be able to re-create the copy

I'd rather find out exactly how to "dispose" of the Excel event which starts
as a result of the WebBrowser being used to open and view an Excel file.

Entirely separate I also have a similar problem with an app that uses
WebBrowser to view a PowerPoint file ..... but in that case I've happily
accepted the "killing" of any process named "PowerPoint" as a solution .....
that solution is not an option in this app.

Michael
"Robinson" wrote:

Does anyone have any suggestions. Is there a way to open the Excel
document
in the WebBrowser as "read only" so the other external app can continue to
use it. Or a way to dispose of Excel after the WebBrowser navigates away
from
the Excel document

Ay help or pointers would be appreciated.


Although I'm not sure on the specifics of your application (most often
failure to "dispose" is caused by not releasing COM references; but as you
say you aren't using InterOp), you could make a copy of the file locally if
it's just going to be readonly - then refresh it if you detect a change in
the original source file (by checking the modified time)?
Sep 21 '06 #3

P: n/a
Hi

for anyone interested I've established a solution.

The process kicked off by the WebBrowser has no MainWindowTitle.

The following will therefore kill the process initiated by WebBrowser but
leave alone any other Excel process already running

Dim myProcesses() As Process
Dim myProcess As Process

myProcesses = Process.GetProcessesByName("Excel")
If myProcesses.Length 0 Then
For Each myProcess In myProcesses
If myProcess.MainWindowTitle = "" Then
myProcess.CloseMainWindow()
Try
myProcess.Kill()
Catch
End Try
Else
' do nothing
End If
Next
End If

Michael Bond

"mabond" wrote:
Hi

recently read a posting and reply about Excel processs still running after
the Appliction.Quit was called. Thought I might be able to use the same
(System.Runtime.InteropServices.Marshal.ReleaseCom Object(exApplication)) to
solve my problem but could not.

Background :
My app uses a WebBrowser control to display to the user the contents of an
Excel spreadsheet.:

Dim oDocument As Object
Dim sName As String = "thefile.xls"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.Navigate(sName)
End If

Private Sub AxWebBrowser2_NavigateComplete2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Even t)
oDocument = e.pDisp.Document
End Sub

Every fifteen minutes another app obtains (via FTP) a raw "csv" file from an
external source, manipulates the file in various ways and saves the new file
to "thefile.xls"

The problem
The FTP process cannot save "thefile.xls" in the event that it is open in
the WebBrowser control of a user who is viewing the file

Attempted fixes.
FileSystemWatcher event looks for arrival of the FTP'd file and clears the
content of the WebBrowser control. Not successful since the Excel process is
still running and the Process is still holding the "thefile.xls" file open
although the WebBrowser may have navigated away from the file. The only way
to clear the Browser is to "kill" the Excel process. I could do that by
looping through each running instance of the process name "excel" and killing
it.....but that's a sledge hammer to crack a nut....I only need to close the
process that is being used by the WebBrwoser control. Since I'm not accessing
Excel as an Interop Com object I can't close it that way.

Does anyone have any suggestions. Is there a way to open the Excel document
in the WebBrowser as "read only" so the other external app can continue to
use it. Or a way to dispose of Excel after the WebBrowser navigates away from
the Excel document

Ay help or pointers would be appreciated.

Regards

Michael Bond
Sep 22 '06 #4

P: n/a
Your solution, while it works, will also leave memory leaks until all
"named" instances of Excel are closed. Just be aware of this limitation.

Mike Ober.

"mabond" <ma****@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
Hi

for anyone interested I've established a solution.

The process kicked off by the WebBrowser has no MainWindowTitle.

The following will therefore kill the process initiated by WebBrowser but
leave alone any other Excel process already running

Dim myProcesses() As Process
Dim myProcess As Process

myProcesses = Process.GetProcessesByName("Excel")
If myProcesses.Length 0 Then
For Each myProcess In myProcesses
If myProcess.MainWindowTitle = "" Then
myProcess.CloseMainWindow()
Try
myProcess.Kill()
Catch
End Try
Else
' do nothing
End If
Next
End If

Michael Bond

"mabond" wrote:
Hi

recently read a posting and reply about Excel processs still running
after
the Appliction.Quit was called. Thought I might be able to use the same
(System.Runtime.InteropServices.Marshal.ReleaseCom Object(exApplication))
to
solve my problem but could not.

Background :
My app uses a WebBrowser control to display to the user the contents of
an
Excel spreadsheet.:

Dim oDocument As Object
Dim sName As String = "thefile.xls"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.Navigate(sName)
End If

Private Sub AxWebBrowser2_NavigateComplete2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Even t)
oDocument = e.pDisp.Document
End Sub

Every fifteen minutes another app obtains (via FTP) a raw "csv" file
from an
external source, manipulates the file in various ways and saves the new
file
to "thefile.xls"

The problem
The FTP process cannot save "thefile.xls" in the event that it is open
in
the WebBrowser control of a user who is viewing the file

Attempted fixes.
FileSystemWatcher event looks for arrival of the FTP'd file and clears
the
content of the WebBrowser control. Not successful since the Excel
process is
still running and the Process is still holding the "thefile.xls" file
open
although the WebBrowser may have navigated away from the file. The only
way
to clear the Browser is to "kill" the Excel process. I could do that by
looping through each running instance of the process name "excel" and
killing
it.....but that's a sledge hammer to crack a nut....I only need to
close the
process that is being used by the WebBrwoser control. Since I'm not
accessing
Excel as an Interop Com object I can't close it that way.

Does anyone have any suggestions. Is there a way to open the Excel
document
in the WebBrowser as "read only" so the other external app can continue
to
use it. Or a way to dispose of Excel after the WebBrowser navigates away
from
the Excel document

Ay help or pointers would be appreciated.

Regards

Michael Bond


Sep 23 '06 #5

P: n/a
Ok Mike,

thanks for that

Michael Bond

"Michael D. Ober" wrote:
Your solution, while it works, will also leave memory leaks until all
"named" instances of Excel are closed. Just be aware of this limitation.

Mike Ober.

"mabond" <ma****@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
Hi

for anyone interested I've established a solution.

The process kicked off by the WebBrowser has no MainWindowTitle.

The following will therefore kill the process initiated by WebBrowser but
leave alone any other Excel process already running

Dim myProcesses() As Process
Dim myProcess As Process

myProcesses = Process.GetProcessesByName("Excel")
If myProcesses.Length 0 Then
For Each myProcess In myProcesses
If myProcess.MainWindowTitle = "" Then
myProcess.CloseMainWindow()
Try
myProcess.Kill()
Catch
End Try
Else
' do nothing
End If
Next
End If

Michael Bond

"mabond" wrote:
Hi
>
recently read a posting and reply about Excel processs still running
after
the Appliction.Quit was called. Thought I might be able to use the same
(System.Runtime.InteropServices.Marshal.ReleaseCom Object(exApplication))
to
solve my problem but could not.
>
Background :
My app uses a WebBrowser control to display to the user the contents of
an
Excel spreadsheet.:
>
Dim oDocument As Object
Dim sName As String = "thefile.xls"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.Navigate(sName)
End If
>
Private Sub AxWebBrowser2_NavigateComplete2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Even t)
oDocument = e.pDisp.Document
End Sub
>
Every fifteen minutes another app obtains (via FTP) a raw "csv" file
from an
external source, manipulates the file in various ways and saves the new
file
to "thefile.xls"
>
The problem
The FTP process cannot save "thefile.xls" in the event that it is open
in
the WebBrowser control of a user who is viewing the file
>
Attempted fixes.
FileSystemWatcher event looks for arrival of the FTP'd file and clears
the
content of the WebBrowser control. Not successful since the Excel
process is
still running and the Process is still holding the "thefile.xls" file
open
although the WebBrowser may have navigated away from the file. The only
way
to clear the Browser is to "kill" the Excel process. I could do that by
looping through each running instance of the process name "excel" and
killing
it.....but that's a sledge hammer to crack a nut....I only need to
close the
process that is being used by the WebBrwoser control. Since I'm not
accessing
Excel as an Interop Com object I can't close it that way.
>
Does anyone have any suggestions. Is there a way to open the Excel
document
in the WebBrowser as "read only" so the other external app can continue
to
use it. Or a way to dispose of Excel after the WebBrowser navigates away
from
the Excel document
>
Ay help or pointers would be appreciated.
>
Regards
>
Michael Bond

Sep 25 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.