Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228

    Open Access 2016 With Batch File

    We just upgraded to Office 2016. How do I use a batch file to run a macro in Access 2016? I used to run a batch file that reads the following... how do I adjust it?



    C:
    CD\Program Files (x86)\Microsoft Office 2007\Office12
    MSACCESS.EXE "S:\Warranty Returns\WRA Data Storage\Warranty Returns - Back End.accdb" /x Overnight Chain
    exit

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Have you tried to replace the path to the 2007 MSACCESS.EXE with the new one? Should be something like \Program Files (x86)\Microsoft Office\Office16
    CD\Program Files (x86)\Microsoft Office 2007\Office12
    MSACCESS.EXE "S:\Warranty Returns\WRA Data Storage\Warranty Returns - Back End.accdb" /x Overnight Chain

    Cheers,
    Vlad

  3. #3
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    That was my first thought, no success though. There is no MSACCESS.exe in the directory "C:\Program Files (x86)\Microsoft Office\Office16"

    I took a look at my Access shortcut and it points at "C:\Program Files (x86)\Microsoft Office\root\Office16" however when I use that directory, it doesn't open anything.

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    You must have the 64 bit version then; look in Program Files instead of Program Files (86).

    Cheers,
    Vlad

  5. #5
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    The only filepaths I have are...

    C:\Program Files\Microsoft Office\Office15\
    C:\Program Files\Microsoft Office 15\ClientX64\

    Neither have a MSACCESS.exe file.

  6. #6
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Do you see a root subfolder?

    https://answers.microsoft.com/en-us/...7e0-437e-9ef3-

    Cheers,
    Vlad

  7. #7
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    Negative, no root subfolder.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Here is my VBScript code:

    Set accessApp = CreateObject("Access.Application")
    accessApp.OpenCurrentDataBase "C:\Users\June\LL\Umpires.accdb"
    'accessApp.UserControl = True
    accessApp.Run "Test" 'call VBA procedure
    accessApp.DoCmd.RunMacro "TestMacro" 'call macro
    accessApp.Quit
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    C:\Program Files (x86)\Microsoft Office\root\Office16
    put that path into a file explorer window, click the navigation arrow and see if MSACCESS.EXE is there in the list of files. If it's not, you don't have it on the pc (at least in that location). You might be dealing with a run time file. If it's there, then your switch may be the problem (/x Overnight Chain).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    Micron, that file is indeed there. However, when I use that folder nothing happens by running the batch file.

  11. #11
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    June7,

    I adapted your code to my filepath and macro, however I'm getting the error...
    "ActiveX component can't create object: 'Access.Application'"

    Set accessApp = CreateObject("Access.Application")
    accessApp.OpenCurrentDataBase "S:\Quality\PQG\Gary\Impromptu.accdb"
    'accessApp.UserControl = True
    'accessApp.Run "Test" 'call VBA procedure
    accessApp.DoCmd.RunMacro "Update Chain" 'call macro
    accessApp.Quit

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Sorry, don't get the error and since I can't replicate issue, have no idea how to correct.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    is the location of the db you are trying to open a trusted location?
    Vlad

  14. #14
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    It is not, I just spoke with IT as the option to add a trusted location is grey'd out.

    Is it a feature of the "Trusted Location" to not allow programmatic launch?

  15. #15
    Gicu's Avatar
    Gicu is online now VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    I believe so, see this thread for more info:https://social.msdn.microsoft.com/Fo...orum=accessdev

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-03-2017, 09:25 PM
  2. Open and log in to database through batch file
    By spacekowboy in forum Access
    Replies: 9
    Last Post: 11-02-2015, 03:22 PM
  3. Replies: 12
    Last Post: 06-27-2013, 07:29 AM
  4. Creating Batch File Running Access Query
    By tcheck in forum Access
    Replies: 1
    Last Post: 12-20-2012, 01:50 PM
  5. Replies: 6
    Last Post: 09-14-2012, 11:58 AM

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