WebBrowser Control!

Hi All,
I am using the WebBrowser Control to show files on the local hard disk..
After navigate to the specified file..i need to clear the navigation, i mean to not show the file within the browser(close it)...
I don't how to do this!!!
Any comment will be very helpfull...
Thanx in advanced...
samjav
samjavAsked:
Who is Participating?
 
Chuckie_IceConnect With a Mentor Commented:
Just a guess,

WebBrowser1.Navigate2 "about:blank"
0
 
aelatikConnect With a Mentor Commented:
You can clear the page like this :

WebBrowser1.Navigate "about:blank"
0
 
BurbbleCommented:
Also you could unload/reload the form that has the browser on it, but this may not work depending on how you have your program set up..

-Burbble
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
samjavAuthor Commented:
i used the
WebBrowser1.Navigate "about:blank"
but the file still opened...
I am using the webbrowser control within a UserControl Iin an ActiveX Control project...
0
 
Chuckie_IceCommented:
Wait, what Sub are you putting WebBrowser1.Navigate "about:blank" under?
0
 
samjavAuthor Commented:
still didn't work...
i am putting WebBrowser1.Navigate "about:blank" within a sub called,when clicking button..
i don't know what the problem is??
0
 
aelatikCommented:
Can you post your entire code ?
0
 
samjavAuthor Commented:
1- The follwoing sun open the file in the WebBrowser Control...
Private Sub cmdOpenObject_Click()
On Error GoTo errorhandler
    CommonDialog1.fileName = ""
    CommonDialog1.Filter = "Office Files (*.doc;*.xls;*.ppt;*.pps;*.rtf;*.txt)|*.doc;*.xls;*.ppt;*.pps;*.rtf;*.txt|PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
          CommonDialog1.ShowOpen
          WebBrowser1.SetFocus
          WebBrowser1.Navigate  CommonDialog1.fileName
    Exit Sub
errorhandler:
   MsgBox "Error while openning the object: -" & Err.Description
End Sub

2- The second one supposed to close it...

Private Sub cmdClose_Click()
   WebBrowser1.Navigate2 "about:blank"
End Sub

0
 
BurbbleCommented:
The code works for me, and while I am not sure why you are using a WebBrowser to display files it does seem to function adequately :-)

Use the Navigate2 method in both cases.

Also, you can go Back and Forward through the previously opened files. I'm not sure how to clear the location history of a WebBrowser control, or if it can be done without unloading and reloading it. Hmm...

-Burbble
0
 
aelatikCommented:
It works with me to, no problems at all.
But i still would like to clear things up about the "navigate" and "navigate2" function

The only difference between them is that "navigate2" can handle navigation to special folders in the Shell Namepace (PIDL).
For example, this would open the fonts folder : WebBrowser1.Navigate2 &H14 ' same as 20

So it does not mather whether you use "navigate" or "navigate2"....
0
 
BurbbleCommented:
Ooh, okay. I did not understand the MSDN article on that correctly; thanks for the clarification.

-Burbble
0
 
nichiaCommented:
Hi Samjav

Here is another KB from MS:

SYMPTOMS
When hosting a WebBrowser control inside an ActiveX Document or an ActiveX Control, which in turn are hosted inside Internet Explorer, the WebBrowser control might not always behave as expected.
CAUSE
The WebBrowser control was not designed or tested to be used in an application that will ultimately be hosted in Internet Explorer.
RESOLUTION
Do not use WebBrowser control in above scenario.
STATUS
This behavior is by design.

http://support.microsoft.com/default.aspx?scid=kb;en-us;237685

Hope it helps!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.