Script to open Access database, run macro, and persist Access instance

前端 未结 2 1518
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 05:55

I would like to have a script to:

  1. Open an Access .accdb file
  2. Run a macro within the database
  3. Leave this open

I can very easily

2条回答
  •  遥遥无期
    2020-12-06 06:23

    If you want to leave the application open after the script completes you need to set the UserControl property to true.

    dim accessApp
    set accessApp = createObject("Access.Application")
    accessApp.visible = true
    
    accessApp.UserControl = true
    
    accessApp.OpenCurrentDataBase("C:\path.accdb")
    accessApp.Run "myLinker"
    

    The Visible property is technically unnecessary when the UserControl property is true. It will automatically be set.

    More information here: http://msdn.microsoft.com/en-us/library/office/ff836033.aspx

提交回复
热议问题