Web Browser Control: Navigate and Set Document Text as well

NiravVyas

Member
Joined
Dec 10, 2010
Messages
8
Programming Experience
1-3
HI,

In my app I am using a web browser control, I am displaying a list of files that are there in selected Directory, when the file type is of some image I do it as

WebBrowser1.Navigate(sFileName), the image is then displayed in the Web Browser Control, when there is Word Doc I had code that converts the word doc to HTML and it is displayed in the WB Control all good so far, now when the file is of type xls, xlsx I am not converting the file to HTML instead I just use the navigate command and open the file in Excel so that user can then edit it and save it on his system. Now the problem is lets say I am toggling through pages in Directory first file is Image so it will be displayed next when it is Excel file then it will open the file in MS Excel but the WebBrowser COntrol has that previously opened image, I want to clear that when the excel file is opened. So here is what I tried.

WebBrowser1.DocumentText = "Some Text"
WebBrowser1.Navigate(sFileName, False)

When I use above code it displays the value "Some Text" in web browser control but it does not navigate to the excel file, on the other hand when I do

WebBrowser1.Navigate(sFileName, False)
WebBrowser1.DocumentText = "Some Text"
It navigates to Excel file but does not display text and the image from previous file persists in the web browser control.I even tried to navigate it to "about:blank" but it then does not navigate to Excel file.

Any ideas !!! Am I am doing anything silly. Please advice..

Thanks
Nirav Vyas
 

ss7thirty

Well-known member
Joined
Jun 14, 2005
Messages
455
Location
New Jersey, US
Programming Experience
5-10
The web browser is meant to view websites, I do not believe opening office documents will work. You cannot even do this with IE, Firefox, Chrome, etc.
 

NiravVyas

Member
Joined
Dec 10, 2010
Messages
8
Programming Experience
1-3
Issue Has Been Fixed...

HI ss7thirty,

I had already being using the web browser control for opening the images, word doc, pdf etc, please let me know if you want to know how. And my issue is also fixed, I had used the document_completed event to assign text to WB control after it has navigated to Excel file.


Thanks
 
Top Bottom