ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   could someone look at my code please and tell me what's wrong? tha (https://www.excelbanter.com/excel-programming/381105-could-someone-look-my-code-please-tell-me-whats-wrong-tha.html)

Blondie

could someone look at my code please and tell me what's wrong? tha
 
Sub RunAccessMacro()

Dim appAcc As Access.Application

'Opens Access or gets reference to app already running

Set appAcc = New Access.Application

'Optional to show or hide Access
appAcc.Visible = True

appAcc.OpenAccessProject
"P:\Analytic\Heather\Individual\IndividualTurnover Report.mdb"

appAcc.DoCmd.RunMacro "Macro1: Get Data"
appAcc.DoCmd.RunMacro "Macro2: Create Report"

'Close Access
appAcc.Quit

'This will close Access, even w/o the 'Quit' command
Set appAcc = Nothing

End Sub

Norman Yuan[_2_]

could someone look at my code please and tell me what's wrong? tha
 
See comment inline.


"Blondie" wrote in message
...
Sub RunAccessMacro()

Dim appAcc As Access.Application

'Opens Access or gets reference to app already running

Set appAcc = New Access.Application

'Optional to show or hide Access
appAcc.Visible = True

appAcc.OpenAccessProject
"P:\Analytic\Heather\Individual\IndividualTurnover Report.mdb"



Application.OpenAccessProject() is used for opening Access project file
(*.adp), not *.mdb.

You should use

appAcc.OpenCurrentDatabase
"P:\Analytic\Heather\Individual\IndividualTurnover Report.mdb"



appAcc.DoCmd.RunMacro "Macro1: Get Data"
appAcc.DoCmd.RunMacro "Macro2: Create Report"

'Close Access
appAcc.Quit

'This will close Access, even w/o the 'Quit' command
Set appAcc = Nothing

End Sub





All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com