1.

Solve : Outlook 2k7 - open a mdb in VBA?

Answer»

hi peeps,

I need to know some VBA for outlook, i know what i'm doing in Access, but this needs to all be done in outlook.

I'm having trouble opening an external .mdb in VBA in outlook, normally in Access i would use the CurrentDB object. I just need to know if there is a way in code to open an mdb in outlook and assign it to a Database Variable so i can manipulate it in a way i am familar with.

Is this possible, if not how would i open the external mdb in outlook?

Thanks in advance you could use DAO.

In the VBA Editor, choose Tools->References

Look for "Microsoft DAO 3.6 Object Library" and add it (check it).


You can create a "Database" Object from a given filename using the following FUNCTION:


Code: [Select]Public Function LoadDatabase(ByVal Filename As String) As Database

Dim returndb As Database
Set returndb = DAO.OpenDatabase(Filename)
Set LoadDatabase = returndb

End Function


Generally, you can use the returned Database as needed in VBA (as you might use CurrentDB). Make sure to close it, though, OTHERWISE things can get hairy. (Normally Access keeps the database open, since it is using it, but with outlook you've created the database object yourself so it's up to you)Dude. LEGEND!!!!!!!!!!!!!!

Do you have ANY idea how long its taken me to squeeze that simple piece of INFO out of the INTERNET???

THANK YOU!!!!!!!!

XD



Discussion

No Comment Found