Results 1 to 18 of 18

Thread: [RESOLVED] Difficult webbrowser question :)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    Resolved [RESOLVED] Difficult webbrowser question :)

    Dear all,

    i have been googling this issue for some time but have drawn a blank.

    I have a webrowser on my form which works well. Web pages change within the webbrowser. However, there are instances where i click a link and rather than opening up within the webbrowser,the page opens up with internet explorer 9. How can i disable this so that all links are opened up within the webrowser.

    Any help would be greatly appreciated

    Sparkash

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: Difficult webbrowser question :)

    Is this even after clearing your cache?

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: Difficult webbrowser question :)

    There IS a small possibility that those pages you are trying to open are configured for Internet Explorer only (or IE and possibly some others), so if it gets a request from an unrecognized webbrowser, it may open in its default.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    Re: Difficult webbrowser question :)

    Hi SamOscarBrown, Thanks for your reply.
    Yes, i have cleared the cache. On the webpage i am accessing, all links to other internal webpages are viewed within the webbrowser. However, the links that open up in IE are PDF documents.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: Difficult webbrowser question :)

    Ah......look at your extension assignments in windows explorer....see what .pdf are linked to.

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: Difficult webbrowser question :)

    In Win7, go to: Control Panel\Programs\Default Programs\Set Associations
    In XP, go to: Windows Explorer, Tools, Folder Options, File Types Tab

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    Re: Difficult webbrowser question :)

    The *.pdf are linked to Adobe Reader 9.4

  8. #8
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Difficult webbrowser question :)

    Try this:

    Code:
    'Click WebBrowser1's NewWindow2 event from the two comboboxes in the IDE
    
    Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    
        Select Case MsgBox("[Yes] Open link in a new window" & vbNewLine & _
                           "[No]  Open link in Internet Explorer", _
                           vbQuestion Or vbYesNoCancel Or vbDefaultButton3)
    
            Case vbYes:    With New Form1 'Change to your Form's name
                                Set ppDisp = .WebBrowser1.Object
                               .Show
                           End With
    
            Case vbNo:    'Link will open in Internet Explorer
    
            Case vbCancel: Cancel = True
    
        End Select
    End Sub
    Still can't get it to open in the same browser though...
    Last edited by Bonnie West; Nov 22nd, 2012 at 09:32 AM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  9. #9
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Difficult webbrowser question :)

    Adobe Reader probably has a setting that tells IE not to open PDF links in a new browser.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    Re: Difficult webbrowser question :)

    Hi Bonnie West, yes i have found a setting within preferences with Adobe Reader which tells it not to open a PDF using Internet Explorer.However, instead the PDF is downloaded and opened up within the PDF reader, rather than opening up in the Browser control. Hmmmm....

  11. #11
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Difficult webbrowser question :)

    I haven't been able to force the WebBrowser control to open all links within the same window, the best I could come up was post #8. Sorry...
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    Re: Difficult webbrowser question :)

    Thanks for your efforts Bonnie, much apppreciated.

  13. #13
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Difficult webbrowser question :)

    Can't you opened the .pdf when downloaded with te webbrowser

    Ex

    WebBrowser1.Navigate "C:\MyPDF.pdf"

    Not testes but i would think you could save all downloads to a temp and then delete when app is closed.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    Re: Difficult webbrowser question :)

    Hi Max187Boucher,

    This is the crux of my problem. The PDF will not open up within the WEbbrowser1 control. Otherwise i could then download it to a local file.

  15. #15
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Difficult webbrowser question :)

    To click on a link in WebBrowser1 and have that link open up in WebBrowser1 you might try this:

    Code:
    Private WithEvents NewWebBrowserWindowHandler As SHDocVwCtl.WebBrowser_V1
    
    Private Sub Command1_Click()
     WebBrowser1.Navigate "www.vbforums.com"
    End Sub
    
    Private Sub Form_Load()
     Set NewWebBrowserWindowHandler = WebBrowser1.Object 'Your webrowser control comes here..
    End Sub
    
    Private Sub NewWebBrowserWindowHandler_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
     
     '
     ' You could also have WebBrowser2 and use
     ' that one for the links
     '
     WebBrowser1.Navigate URL
      
     Processed = True 'Tell the control, your code have processed the event, there's no need to open the new window
    End Sub


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    Re: Difficult webbrowser question :)

    Wow, Thanks jmsrickland, It works a treat now. Exactly what i wanted.

    Ultimate respect to you!

    Cheers

  17. #17
    Junior Member
    Join Date
    May 2009
    Posts
    25

    Re: [RESOLVED] Difficult webbrowser question :)

    Hi,
    Just wrestling with the same problem
    did a search.. and this code works perfectly

    Thanks from me also to jmsrickland

  18. #18
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: [RESOLVED] Difficult webbrowser question :)

    Code:
    Private Sub Form_Load()
    WebBrowser1.Silent = True
    End Sub
    
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    WebBrowser1.Silent = True
    End Sub
    
    Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    Cancel = True
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width