pete1234 Posted August 26, 2008 Posted August 26, 2008 I'm trying to program a few tasks I normally do in Excel and Access into AutoIt, and while I've gotten the basics done, I'm struggling to port over some VBA code. For example, I have this code to essentially filter a report based on a date I enter into a text box: Const conDateFormat = "\#mm\/dd\/yyyy\#" strReport = "rptProgramSetup" strField = "ProgramEnd" ; Irrelevant code strWhere = strField & " Between " & Format(Me.txtStartDateMenu, conDateFormat) _ & " And " & Format(Me.txtEndDateMenu, conDateFormat) DoCmd.OpenReport strReport, acViewPreview, , strWhere I can get the report to open fine like so: $AccessApp = ObjCreate("Access.Application") ; Irrelevant code $AccessApp.DoCmd.OpenReport("rptProgramSetup").acViewPreview But it sends it directly to the printer rather than opening in Print Preview mode. I'm having similar issues with the other arguments of OpenReport. I was hoping someone could help me out with this, or perhaps point me in the direction of a useful developer's reference for doing this sort of stuff. Thanks a bunch.
pete1234 Posted August 26, 2008 Author Posted August 26, 2008 (edited) Well I figured out how to run a macro from AutoIt: With $AccessApp. .OpenCurrentDatabase ($Database) ; Irrelevant $DummyVar = .Run("MyMacro") EndWith But this only works if MyMacro is defined as a public function in a module. It doesn't seem to work for subroutines or functions in a form. Any ideas? Edited August 26, 2008 by pete1234
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now