Import bas file into Access (1 Viewer)

Linalool

New member
Local time
Today, 12:53
Joined
Jul 7, 2009
Messages
1
Hi, I have a bas file and I want to import it into 150 databases. I have been trying to find a way to do this in VBA and not come up with anything. Does anyone know how to do this?

Thanks in advance,
Matt
 

ajetrumpet

Banned
Local time
Today, 14:53
Joined
Jun 22, 2007
Messages
5,638
you need a way to loop through all of the databases you want to open. i don't know if you would need to open them or not, but if you do, make sure you open them and set the focus to them. then, each time through your loop, use this code to get the module:
Code:
Dim Acc As Access.Application

Acc.OpenCurrentDatabase "FULL PATH OF DB TO OPEN AND IMPORT TO"

Application.VBE.ActiveVBProject.VBComponents.Import "PATH OF THE .bas FILE"

DoCmd.Save acModule, "NAME OF THE .bas FILE"
 

HiTechCoach

Well-known member
Local time
Today, 14:53
Joined
Mar 6, 2006
Messages
4,357
Welcome to AWF!

I have found that whenever you import a .bas file, it is also very, very important to manually compile the VBA code before you close the database. Depending on what version of Access you are using, it is possible to corrupt ALL the VBA code in a database if you do not do the compile before you exit the database.

I would also make sure you have a good backup of the database before you import the .bas file.

This may also be helpful: http://www.autohotkey.com/
 

Users who are viewing this thread

Top Bottom