Consulting

Results 1 to 3 of 3

Thread: Opening up an Access File

  1. #1
    VBAX Newbie
    Joined
    Dec 2012
    Posts
    1
    Location

    Opening up an Access File

    So I am using Excel to open up an Access file within a program I am making for class. The Access file opens up just fine, however, when I close out of the file, I get error '424 object required' and says the error is with the oApp.Visible = True line. I just want to know what this means and what I need to do to make the error not come up, below is the code I have.

    Sub OpenAccessFile()

    'Open Access and make visible
    Set oApp = GetObject("E:\Documents\Info 395\BYBDatabase.accdb")

    oApp.Visible = True

    App.OpenCurrentDatabase LPath

    TrustedApplication = yes



    End Sub

  2. #2
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    In your example the object is the File, not the Application. I don't work with Access in VBA (so I might be off track) but I would try oApp.Parent.Visible = True.
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  3. #3
    Hey autoxguy,

    Here's two simple methods of opening any file type (Access in this case):

    Option Explicit
    Sub Macro1()
     
        'Two methods to any file - Access in this case
        'Written by Trebor76
        'Visit my website www.excelguru.net.au
     
        'Method 1
        CreateObject("Shell.Application").ShellExecute "E:\Documents\Info 395\BYBDatabase.accdb"
     
        'Method 2
        ActiveWorkbook.FollowHyperlink "E:\Documents\Info 395\BYBDatabase.accdb", NewWindow:=True
     
    End Sub
    HTH

    Robert

Posting Permissions

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