views:

190

answers:

0

VB.NET 2008 - WinForms

Hi Everyone!

I've been looking for an answer to my problem but I only find more questions related to my problem...

The thing is that I'm using a AxWebBrowser control in VB.NET 2008 to open a excel file in a WindowsForm, it opens succesfully and everything... but the problem is this:

If I had a Excel File Open before opening another Excel File in my WebBrowser Control, the window that contains the file that was already open gets locked... (I can't give focus to that Excel window... If I click on it, the focus returns to my application)

I tried creating a new excel instance with CreateObject("Excel.Application") just before loading the file, but the WebBrowser locks the first Excel Instance...

Is there a way to lock it to the last instance???

I use the WebBrowser1.Navigate(Url) method to load the file... where Url is a String like C:\myExcelFile.xlsm

WebBrowser1.Document.Application.UserControl is also True, but it get's locked.

Any Suggestion??

Thanks in Advance!!!

How to Reproduce: 1. Create a new project

  1. Insert 1 button named "Button1"

  2. Insert 1 AxWebBrowser Control (the icon is a world, if you can't find it, look for it in "Tools - Choose Toolbox Items - COM Components" and select "Microsoft Web Browser")

  3. Change the URL in the AxWebBrowser1.Navigate("URL STRING") Method in the Button1_Click Event

  4. Open any Excel file Already Saved (Different from the URL file)

  5. then execute and press the button in the new application

Remember, the Excel file that you open, must be already saved

The Application should load the Excel File that you specify in the URL and you should be unable to continue working on the other Excel file... that is what I don't Want... if you do the same but in a Explorer Window, that doesn't happen...

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    AxWebBrowser1.Navigate("\\SomeFolder\720-05052.xlsm")
End Sub

Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    Application.Exit()
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    AxWebBrowser1.Dispose()
End Sub
End Class