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

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.

Related

Creating a working copy of an old Access 2010 database

I am tasked with fixing some bugs that an access 2010 database, written 10 or so years ago, has. The database has been functioning but has a few bugs in report generation that need to be fixed (ie: bugs are not impeding overall functionality).
Since I am relatively new to access 2010, I wanted to create a working copy of the entire database, VBA and all, so that I could get into the VBA code and figure out what is causing the bugs without accidentally sending some of the automatic emails or changing pertinent information in the data. I have tried saving the database with a new name, copying it in the folder and pasting elsewhere, and creating a backup and saving that elsewhere.
Each attempt yields the same issue: the VBA project not being readable. It gives the following message when I open any copy:
if included picture doesn't load: tl/dr: database cant be opened because VBA project cant be read, if "ok" is clicked vba project will be deleted..I have searched high and low, asked everyone that has used the database, nobody knows how to fix the issue and I do not feel comfortable changing anything in the live copy.
Any assistance would be greatly appreciated. Thank you in advance.
One option you might try is to create a new blank database file and attempt to import all of the database objects from a copy of your target database into the new database file using the import wizard. If that's successful it won't be an exact replica of the previous database with regards to settings, but will include all of the database objects/code at least.

Cannot access any VBA Modules in MS Access 2016

My VBA Project seems to be corrupted. When I try to open a module I get a "Module name 'xxxx' is misspelled or relates to a module that doesn't exist". This all seemed to happen after a run time error inferring a corruption had taken place. I have tried to open Access in decompile mode and then open the data base, but still no luck...though I'm not sure how you tell its in decompile mode. I'd desperately like to get some code out that I've been working on for a couple of days.... I can open the tables and queries, so it seems its just the VBA project.
Any ideas? is there a way of accessing the modules outside of the data base?

Creating Spreadsheet from SQL using ASP - Can I attach macros?

So I have been using ASP for all of a week now and perhaps this is something that I just can't do, but I am trying to dynamically generate reports from data stored in a SQL database. I am publishing the reports through an ASP document and displaying by specifying Excel for the MIME content type:
Response.Buffer = TRUE
Response.ContentType = "application/vnd.ms-excel"
Is it at all possible to "attach" macros to the document? I understand I can do basic formatting in the HTML, but I would prefer to import the desired database data and handle it within excel via macros.
EDIT:
I have several reports I need to generate but for one example:
I want to load retrieved data from the database into a sheet in excel.
Attach Macro
Begin Macro:
Hide the specified sheet.
Programatically create new sheets for categories of data.
Format sheets.
The question is not about how to program the macro, just whether or not a macro can be attached and how to achieve this. In regards to alerts upon opening the sheet, if I can attach macros I should, theoretically, be able to suppress those in the Open Workbook event.
EDIT: I believe I can achieve the desired result by using OWC (Office Web Components) (see http://support.microsoft.com/default.aspx?scid=kb;EN-US;288130). However, I am not sure if I will be able to install it on our Web Server. Any other suggestions?
While it is possible in a strictly technical sense, it is neither simple nor advisable. The recipient of the sheet will get multiple prompts related to the security of your macros; the source of your macros; and if they really, truly, honestly meant to click to enable macros...

How to programatically call a macro in a different (ie. external) Access database using 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

creating an excel add-in

can someone please get me started on the following:
i would like to package an excel macro as an add-in to excel. the macro will reside on a central computer, where 10 other computers will connect to.
how do i create an add-in that will be constantly updated ?
According to this you can have an Add-In reside on a network share, so you wouldn't even need to bootstrap and update the code via code. Here's a quick rundown on how to create an Add-In.