473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

WebBrowser - Excel processs till running

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
5 6555
>
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luis Ferrao | last post by:
Hi, My Windows Forms application uses the WebBrowser control to open an Excel file since OLE objects are gone in .Net. The application is actualy a clone of the one found in the MS Knowledge...
2
by: zhangyl | last post by:
I am running a instance of microsoft excel, and then I use the webBrowser to open an excel file in my owner application, but now, the existed instance of microsoft excel can't run, but I can run a...
0
by: zhangyl | last post by:
I want use a webBrowser control in my application to embed excel application. But if I run a instance of microsoft excel at first, and then use the webBrowser to open an excel file in my owner...
1
by: Joe | last post by:
Hi I am able to embed Excel into a WebBrowser on my Dev machine but on a client machine an instance of Excel starts in it's own window. Anyone seen this before??? Thanks
1
by: Joe | last post by:
Hi I have embedded Excel in a WebBrowser on a Form but none of Excels Menus are present Is this the way it is suppose to work??? Do I need to add my own button to print/save excel from...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: morfasie | last post by:
Hi, I am using the code from microsoft Microsoft Webbrowser Excel My problem is, when I click on the excel file to open it, it opens up Office Excel with the file loaded, and nothing happens...
0
by: jwmaiden | last post by:
Have an application that opens up a webbrowser control to display data in an Excel spreadsheet (using VB.NET in VS 2005). No problem with opening the spreadsheet or displaying the data, but I'm...
3
by: BryanGilbert | last post by:
Hello everyone, I am developing one win application which makes use of WebBrowser control.I am passing the url in a text box and the page is getting displayed in the web browser control.Till this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.