Solved

WebBrowser Control!

Posted on 2004-08-01
12
250 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:samjav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 14

Assisted Solution

by:aelatik
aelatik earned 50 total points
ID: 11687456
You can clear the page like this :

WebBrowser1.Navigate "about:blank"
0
 
LVL 7

Expert Comment

by:Burbble
ID: 11687697
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
 

Author Comment

by:samjav
ID: 11687725
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 2

Accepted Solution

by:
Chuckie_Ice earned 50 total points
ID: 11689015
Just a guess,

WebBrowser1.Navigate2 "about:blank"
0
 
LVL 2

Expert Comment

by:Chuckie_Ice
ID: 11689018
Wait, what Sub are you putting WebBrowser1.Navigate "about:blank" under?
0
 

Author Comment

by:samjav
ID: 11691072
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
 
LVL 14

Expert Comment

by:aelatik
ID: 11691271
Can you post your entire code ?
0
 

Author Comment

by:samjav
ID: 11691708
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
 
LVL 7

Expert Comment

by:Burbble
ID: 11694030
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
 
LVL 14

Expert Comment

by:aelatik
ID: 11694675
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
 
LVL 7

Expert Comment

by:Burbble
ID: 11695411
Ooh, okay. I did not understand the MSDN article on that correctly; thanks for the clarification.

-Burbble
0
 
LVL 3

Expert Comment

by:nichia
ID: 11883975
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 23 hours left to enroll

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question