473,626 Members | 3,947 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 .InteropService s.Marshal.Relea seComObject(exA pplication)) 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.xl s"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.N avigate(sName)
End If

Private Sub AxWebBrowser2_N avigateComplete 2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebB rowserEvents2_N avigateComplete 2Event)
oDocument = e.pDisp.Documen t
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.xl s"

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

Attempted fixes.
FileSystemWatch er 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.xl s" 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 6569
>
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.GetProc essesByName("Ex cel")
If myProcesses.Len gth 0 Then
For Each myProcess In myProcesses
If myProcess.MainW indowTitle = "" Then
myProcess.Close MainWindow()
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 .InteropService s.Marshal.Relea seComObject(exA pplication)) 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.xl s"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.N avigate(sName)
End If

Private Sub AxWebBrowser2_N avigateComplete 2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebB rowserEvents2_N avigateComplete 2Event)
oDocument = e.pDisp.Documen t
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.xl s"

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

Attempted fixes.
FileSystemWatch er 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.xl s" 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****@discuss ions.microsoft. comwrote in message
news:23******** *************** ***********@mic rosoft.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.GetProc essesByName("Ex cel")
If myProcesses.Len gth 0 Then
For Each myProcess In myProcesses
If myProcess.MainW indowTitle = "" Then
myProcess.Close MainWindow()
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 .InteropService s.Marshal.Relea seComObject(exA pplication))
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.xl s"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.N avigate(sName)
End If

Private Sub AxWebBrowser2_N avigateComplete 2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebB rowserEvents2_N avigateComplete 2Event)
oDocument = e.pDisp.Documen t
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.xl s"

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

Attempted fixes.
FileSystemWatch er 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.xl s" 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****@discuss ions.microsoft. comwrote in message
news:23******** *************** ***********@mic rosoft.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.GetProc essesByName("Ex cel")
If myProcesses.Len gth 0 Then
For Each myProcess In myProcesses
If myProcess.MainW indowTitle = "" Then
myProcess.Close MainWindow()
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 .InteropService s.Marshal.Relea seComObject(exA pplication))
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.xl s"
If sName.Length Then
oDocument = Nothing
AxWebBrowser2.N avigate(sName)
End If
>
Private Sub AxWebBrowser2_N avigateComplete 2(ByVal sender As _
System.Object, ByVal e As _
AxSHDocVw.DWebB rowserEvents2_N avigateComplete 2Event)
oDocument = e.pDisp.Documen t
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.xl s"
>
The problem
The FTP process cannot save "thefile.xl s" in the event that it is open
in
the WebBrowser control of a user who is viewing the file
>
Attempted fixes.
FileSystemWatch er 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.xl s" 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
6423
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 Base Article "How to Use the WebBrowser Control to Open Office Documents with Visual C# .NET" which can be found here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;304662 The application does what it's supposed to (ie Loads embeded Excel
2
1203
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 new instance of excel. How is it?
0
908
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 application, the existed instance of excel application can't run now, but I can start another new instance of excel. How is it?
1
2724
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
2290
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 webbrowser ??? Thanks
0
5557
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
1245
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 to the webbrowser control? I am using Office 2007? Is that maybe the reason? Please help, I want to open it into my webbrowser control
0
2703
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 having problems with repeating the process. I want to create an Excel spreadsheet, add some data to it, and display the results in a webbrowser control. I want to be able to then later delete the old Excel spreadsheet, create a new one, add some new data,...
3
2187
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 its fine.Whn ever a link is clicked inside the webbrowser control it is opening in the same page.Is there any way such that the clicked links inside a webbrowser control should open in a new tab with the tab having the page title. I tried the...
0
8199
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
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
8638
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...
0
8505
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
7196
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
6125
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
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.