How to programatically call a macro in a different (ie. external) Access database using VBA? - vba

I want to use Access Database1 to call a macro in Access Database2.
The link below describes how to call an external macro in a visio program, but the syntax seems to be a little different with Access.
How can I call a VBA macro that is defined in a different file?
Basically, I want to do something like this (from within database 1)
AccessDatabase=pathToOtherDatabase.mdb
AccessDatabase.runMacroA
Does anybody know how to do this?

You could use the built in Shell command to call your secondary database, and pass it the macro name in the command line switch, this would force your secondary database to execute the desired macro on open. More about Access command line switches can be found here:
http://support.microsoft.com/kb/209207

Related

Call Function via User Interaction with Office Scripts in Excel Online

Is it possible to trigger an Office Scripts function within Excel Online as a result of a user action? For example, can I run a specific Office Scripts function when the user clicks on a hyperlink within Excel Online? If so, can you give an example of the syntax/setup of the hyperlink?
It is not possible to trigger based on user-action; we are investigating allowing trigger through a shape/image (button). Would that be something that'll meet your requirement?
(I work on the product team)
You could try building a Flow (aka "a Power Automate") that is triggered on the "File Change event"(for the Excel file) in SharePoint. Instead of just having the Flow trigger on double-click you would need to enter data into the cell. Because the worksheet and, this, file changed the Flow would trigger. Good luck.

Coding to print PDF files from file paths in query results

I'm not new to Access, but am very new to VBA coding. Our management software is horrible, but it's the best that is available in the industry and I have created many many reports using Access, but have new problem now.
Attachments in the system are stored in one central location and then the file name stored in a SQL table. I have created queries to pull the full file path including the file name. Would it be possible to use some VBA coding to print all the existing PDFs in sequence from the paths returned in the query?
Thank you for any and all help!
Native VBA controls the collections of methods and attributes from Office.
An existent PDF is not the case (Access can create one or open, but not open and print).
To open a file with full path you will need to perform a select from table and perform a loop to shell open file, after that, sendkeys ^P.
But I strongly recomend to use another tool to do it, like Auto Hotkey or AutoIt.

Shared Data Source for Excel

I am currently creating reporting within excel for lets say 'Non Advanced Users'. I Have successfully created this in and I can execute the stored procedure with parameters typed into excel cells. But when I send this to another user it is saying that it is unable to connect to the data source. Is there a way I could tell excel to use a data source on our network. The connection has SQL Authentication. Basically I want to try and avoid having to create data sources via excel on 100+ machines!!
Yes you can. You can save the connection setting in the excel file itself, and just send out that file. See picture below for step-by-step guide.
Remember to CLEAR (uncheck) the 'Always Use Connection File' in Step 6.

Can an Access macro be saved as an add-in to be used in another Access database?

I am doing some work within MS Access and I have come across a rather annoying hurdle. I have written up some code and created a macro to execute said code. My issue is that I would like to be able to execute this macro from any project.
As of right now the only way I can run the macro/code for a new project is to create a new module paste in the code and then create a new macro to run said code. Is there a way to capture this macro/code into an addin or save the macro globally so that it is available any time an access project is open?
You can create a reference to an Access database in the same way as any other reference. Once you do, you can run any code it contains.

Dump MS Access Macro object info from VBA code

I have a project in which I need to compare different versions of an Access 2003 database against each other. We're not interested in the data in the tables. We're only interested in the objects that describe the database. I.e. Form objects, Report objects, QueryDefs, TableDefs etc.. The databases are fairly large so the approach is to dump all the descriptions for objects of interest into a text file by running a VBA app in each of the databases and then comparing the results in a diff viewer.
I've been looking around for several days to find out how to dynamically dump access 2003 macro content from within VBA. Please don't confuse this with dumping VBA code from VBA.
I know about Application.CurrentDB.AllMacros to get a list of macros in the active access database. But I can't get at the macro object from Macro(MacroName).SomeProperty because the macro isn't open. So I've been trying to look for a way to open the macro and haven't found a way to accomplish this through VBA.
Any help on the topic would be appreciated.
Thanks!
You can export macros with the undocument Application.SaveAsText:
Application.SaveAsText acMacro ,"AutoKeys", "AutoKeys.txt"
...saves the AutoKeys macro to whatever the current directory is.
You could manually ask Access to convert the macros to VBA. There is an option for that, I think when you right click the macro. After that you can compare the generated VBA.
See the following page for a list of utilities to compare Access databases
http://www.granite.ab.ca/access/thirdparty.htm