0

I have a MS Access file with 4 buttons that a user has to click 1 by 1 after the previous task completes.

I am trying to automate the file without changing its code. Is it possible to automate it with some library?

There is what the code looks like in Visual Basic

Private Sub Command61_Click()

Call Clear_Feed_Tables

End Sub

Private Sub Command63_Click()

Call Import_Feeds

End Sub

Thank you!

1 Answer 1

1

Consider Python's COM library, win32com, to access the MS Access' object library (same process VBA does). Specifically, call the Application.Run method. Below assumes both methods reside in a standard module (i.e., not behind a form or report). Also, this method does not use any form values (i.e., Forms!myForm!myControl). If user enters values, re-write methods to pass parameters and then have Python pass same values.

import win32com.client

# OPEN ACCESS APP AND DATABASE
oApp = win32com.client.Dispatch("Access.Application")
oApp.OpenCurrentDatabase(r'C:\Path\To\myDB.accdb')

# RUN STANDARD MODULE METHODS
oApp.Run("Clear_Feed_Tables")
oApp.Run("Import_Feeds")

oApp.DoCmd.CloseDatabase
oApp.Quit
oApp = None
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.