Set App = GetObject

Posted on 2006-04-14
Last Modified: 2008-02-01
I need help with this code.  I need to click a command button in excel and open Access to a certain "Form" and Hardcode the password.

I get a code "File name or class name not found during automation operation"

Any help would be greatly appreciated

    'Open a form in Access
    Dim App As Object
       Set App = GetObject("\\Dtcnas-ilsp002\mandatory\Analysts - Working Files\Carol\Demo\Volume.mdb;Jet OLEDB:Database Password=OPPS;")
     App.Application.DoCmd.RunMacro "Macro2CloseSwitchboard"
     App.Application.DoCmd.openform "Form"

Question by:ca1358
    LVL 26

    Expert Comment

    1. don't use app

    app is reserve word in vb

    try something else


    dim App1 as object
    LVL 44

    Accepted Solution

    Perhaps something like

    'Open a form in Access
    Dim objAccess As Object

    Set objAccess = CreateObject("Access.Application")

    With objAccess
        .OpenCurrentDatabase "\\Dtcnas-ilsp002\mandatory\Analysts - Working Files\Carol\Demo\Volume.mdb", , "OPPS"
        .DoCmd.RunMacro "Macro2CloseSwitchboard"
        .DoCmd.OpenForm "Form"
        .UserControl = True
    End With

    Set objAccess = Nothing

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now