VBS Script to Run Macro in Access 2003

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • White Horse

    VBS Script to Run Macro in Access 2003

    I want to nightly run a VBS Script in Scheduled tasks to open an
    Access 2003 database and execute a macro.

    The problem is that the database opens to a switchboard screen. I
    need to open this database with a VBS script that mimicks opening the
    database with {shift} open. My code:


    dim accessApp
    set accessApp = CreateObject("A ccess.Applicati on")
    accessApp.visib le = True
    accessApp.OpenC urrentDataBase( "C:\ACF\Cop ied from Server\ACF.mdb" )
    accessApp.Run "Macro1"
    accessApp.Quit


    When this script executes, the switchboard is open, and the Macro1
    can't be found (executed).


    Thanks


  • JvC

    #2
    Re: VBS Script to Run Macro in Access 2003

    Set up a seperate application with the objects you need to run your macro.
    Attach the tables you need in ACF.mdb
    Give your new mdb an autoexec macro, with the following commands:
    RunMacro with Macro 1 as the Macro name.
    Quit

    Set up the new mdb to run in Scheduled Tasks

    John

    "White Horse" <michael_13143@ msn.comwrote in message
    news:47f791a3-53d7-4657-8be5-f8e46d2a9222@79 g2000hsk.google groups.com...
    >I want to nightly run a VBS Script in Scheduled tasks to open an
    Access 2003 database and execute a macro.
    >
    The problem is that the database opens to a switchboard screen. I
    need to open this database with a VBS script that mimicks opening the
    database with {shift} open. My code:
    >
    >
    dim accessApp
    set accessApp = CreateObject("A ccess.Applicati on")
    accessApp.visib le = True
    accessApp.OpenC urrentDataBase( "C:\ACF\Cop ied from Server\ACF.mdb" )
    accessApp.Run "Macro1"
    accessApp.Quit
    >
    >
    When this script executes, the switchboard is open, and the Macro1
    can't be found (executed).
    >
    >
    Thanks
    >
    >

    Comment

    • Albert D. Kallal

      #3
      Re: VBS Script to Run Macro in Access 2003

      As the other poster suggested, simply setup another mdb file with linked
      tables to the application, and then you good to go. Place you code in a
      standard module, and then your run command will execute that code (your
      script looks just fine).


      --
      Albert D. Kallal (Access MVP)
      Edmonton, Alberta Canada
      pleaseNOOSpamKa llal@msn.com


      Comment

      • White Horse

        #4
        Re: VBS Script to Run Macro in Access 2003

        Thanks for the input.

        I believe this would be a good solution, but unfortunately, I can't
        change the original ACF.mdb database (admin permissions that have
        nothing to do with Access databases). I am permitted to "go through
        the backdoor" by pressing the shift key before clicking open. I tried
        Sendkeys "+", but this did not work.

        I do a great amount of VBA from Excel dealing with Access databases,
        but I couldn't do anything from there, either.

        Mike

        Comment

        Working...