|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WebBrowser - Excel processs till runningrecently 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.ReleaseComObject(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_NavigateComplete2Event) 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 > Although I'm not sure on the specifics of your application (most often > 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. > 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)? 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 Show quoteHide quote "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)? > > > 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 Show quoteHide quote "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.ReleaseComObject(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_NavigateComplete2Event) > 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 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. Show quoteHide quote "mabond" <mab***@discussions.microsoft.com> wrote in message news:23126CFD-3961-44E7-9C3F-C87FFB7B6CB2@microsoft.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.ReleaseComObject(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_NavigateComplete2Event) > > 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 > Ok Mike,
thanks for that Michael Bond Show quoteHide quote "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" <mab***@discussions.microsoft.com> wrote in message > news:23126CFD-3961-44E7-9C3F-C87FFB7B6CB2@microsoft.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.ReleaseComObject(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_NavigateComplete2Event) > > > 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 > > > > > >
Random Numbers Not Being Random
Why is PeekChar causing a problem? passing parms to sql stored procedure Problem Adding new record to a database sqldatareader padding varchar fields with extra white space Image list controls and image resources Q: Copying part of a table Question in re LIKE in VB 2005 Refresh/Blinking Problems with VB.NET Application TcpListener with external/internet IP? |
|||||||||||||||||||||||