Web Browser ActiveX Control

doulostheou

Registered User.
Local time
Today, 08:51
Joined
Feb 8, 2002
Messages
314
I am trying to use the Web Browser ActiveX Control to preview PDF files within my application. I did this a long time ago without problems (Access 97) and the examples I have found online are all straightforward:

Code:
objWebCtrl.Navigate=strPath

Unfortunately, Access 2010 does not appear to realize that the Web Control has a navigate method. I keep getting the following run-time error: Object doesn't support this property or method.

Has the way you interact with this particular ActiveX control changed or is there something I am doing wrong?
 
Unfortuantely, I'm still getting the same error with Navigate2. Here is the full code and the two form objects I am interacting with is a text box that stores the path (txtUpload) and the activex object itself (objWebCtrl):

Code:
Private Sub cmdBrowse_Click()
    Dim cmdlgOpenFile As New clsCommonDialog
    Dim FileName As String    'full file name
    Dim objPreview As Object
    Const clngFilterIndexAll = 5
    
    cmdlgOpenFile.Filter = "All Files (*.*)|*.*|PDF Files (*.pdf)|*.pdf"
    cmdlgOpenFile.FilterIndex = clngFilterIndexAll
    'this is where the dialog opens
    cmdlgOpenFile.ShowOpen
    
    'returns your full file name.
    FileName = cmdlgOpenFile.FileName
    
    'hence no len, no name...
    If Len(FileName) = 0 Then Exit Sub
    txtUpload = FileName
    objWebCtrl.Navigate2 = txtUpload
End Sub

I tried using the object browser and I do not see any methods that function as a navigate command. In the Access library there is a WebBrowserControl class that has a BeforeNavigate2 event and a NavigateError Event, but the only mehtods I see are Move, Requery, SetFocus, SizeToFit, and Undo. Move appears to physically move the coordinates of the location on the screen.

It's almost like this is the wrong control altogether. There is also a SHDocVw library which has a WebBrowser_V1 Class and a WeBrowser class, both of which have a Navigate command. But I'm not sure how to grab ahold of the objects that reference that library.
 
Okay. I feel like an idiot. It is a method not a property, so objWebCtrl.Navigate = txtUpload obviously should become objWebCtrl.Navigate txtUpload. All is working.
 
Code:
objWebCtrl.Navigate strPath

works for me (A2007) - note the absent "="
 
OKie - now I feel like an idiot too :D
 
Sorry for picking up this subject from 2011 but the problem matches my problem so I didn't want to create a new one.
I am also struggeling with displaying pdf in a webbrowser control. I use Navigate method as it was said but still getting the same error: method or data member not found.
I've seen across the internet that people have no problems with it. I do.
Any help?

Code:
Me.web_browser.Navigate pathtofile_variable
 
I don't use this control but the error sounds generic. Does Intellisense list the web_browser control when you type "Me." and does it list Navigate when you type "Me.web_browser."?
 
Yes. After Me. my web_browser is found. But navigate method is not listed. In addition, there even is a reference to Windows Browser Controls enabled.
 
Do this:
Code:
    Dim webControl As WebBrowser
    
    Set webControl = Me.[COLOR="Blue"]web_browser[/COLOR].Object
    
    With webControl
        .Navigate "www.google.com"
    End With
Where web_browser is the control name. That should do it.
 
One more thing, is there a way to open pdfs in a zoomed view without grey fields on the sides? Let's say 120% or to fit the frame.
 
wojtasik6, this is a 2011 thread relating to the Navigate method which your last question doesn't relate to. You can ask this question in a new thread of your own.
 

Users who are viewing this thread

Back
Top Bottom