473,703 Members | 2,328 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 6579
>
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
6436
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
910
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
2729
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
2293
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
5570
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
2707
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
2188
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
8669
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
9251
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
9122
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
8963
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
4433
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3125
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
2
2453
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2069
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.