Results 1 to 3 of 3
  1. #1
    Sense is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Nov 2018
    Posts
    15

    Access 2013 VBA Getting control of open Internet explorer window

    Hi All,



    I decided to drop a question here since I could not find a solution after looking for hours.

    I am working on a DB which gets information from a web page. The script starts with trying to use an open instance of internet explorer.
    This part doesn't work. I have used the script successful in excel, but run into an error when running It with Access:

    "ActiveX component can't create object" (Error 429)

    The part of code is as following:

    Code:
    Sub TestY()
    Dim GetIEatURL As Object
    Dim sMatch As String
    Dim ie As Object
    Dim oShApp As Object
    Dim oWin As Object
    sMatch = "https://www.google.com"
    On Error Resume Next
    Set oShApp = CreateObject("Shell.Application")
    For Each oWin In oShApp.Windows
        If TypeName(oWin.Document) = "HTMLDocument" Then
            Set ie = oWin
            If LCase(ie.LocationURL) Like LCase(sMatch) Then
                Exit For
            End If
        End If
    Next
    Set oShApp = Nothing
    Set oWin = Nothing
    Debug.Print ie.LocationURL
        
    End Sub
    The error happens with the line
    Code:
    Set oShApp = CreateObject("Shell.Application")
    The References I use are:

    Visual Basic For Applications
    Microsoft Access 15.0 Object Library
    Microsoft Excel 15.0 Object Library
    OLE automation
    Microsoft Ofice 15.0 Object Library
    Microsoft Internet controls
    Microsoft Shell Controls and automation
    Microsoft HTML object library
    ExcelPlugInSHell 1.0 Type library

    Any help will be appreciated!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you cant take control of a SHELL app.
    use the object to take control:

    Code:
    Sub IE_Test() 
        Dim ie 
        Set ie = CreateObject("InternetExplorer.Application") 
        ie.Visible = True 
        ie.Navigate url1 
     
    End Sub

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    Duplicate post & this is a duplicate answer!

    If the object has already been created, you need to use GetObject instead of CreateObject

    Code:
    Set oShApp = GetObject(,"Shell.Application")
    NOTE the comma after the left bracket

    Do you really use ALL of those references?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. open pdf viewer without opening internet explorer
    By ChuckRS in forum Programming
    Replies: 0
    Last Post: 04-14-2015, 06:42 PM
  2. Trying to control Internet Explorer in VBA
    By Glenn_Suggs in forum Modules
    Replies: 21
    Last Post: 09-25-2014, 08:44 AM
  3. Find Internet Explorer window based on specific site
    By redbull in forum Code Repository
    Replies: 0
    Last Post: 04-02-2013, 09:19 AM
  4. VBA > Internet Explorer
    By Stokecpa in forum Programming
    Replies: 3
    Last Post: 08-06-2012, 01:10 AM
  5. Internet Explorer automation with VBA
    By sa230e in forum Programming
    Replies: 0
    Last Post: 09-29-2011, 05:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums