ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Open Access Database with VBA (https://www.excelbanter.com/excel-discussion-misc-queries/28778-open-access-database-vba.html)

Keith

Open Access Database with VBA
 

I have created a macro in an Excel workbook to do various things with a web
query, then export one sheet of the workbook as a txt file. I then get the
macro to open Access.

What I am wanting to do is:- I want my macro to, not only open Access, but
to open a specific Access Database and if possible, run a macro within that
database to import the data that I have exported from Excel.

Any ideas?

Thanks



Ron de Bruin

Try this Keith

Sub test()
On Error Resume Next
Set ac = GetObject(, "Access.Application")
If ac Is Nothing Then
Set ac = GetObject("", "Access.Application")
ac.OpenCurrentDatabase "C:\testing.mdb"
ac.UserControl = True
End If
AppActivate "Microsoft Access"
End Sub


I never try to open a macro in Access ?


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Keith" wrote in message ...

I have created a macro in an Excel workbook to do various things with a web query, then export one sheet of the workbook as a txt
file. I then get the macro to open Access.

What I am wanting to do is:- I want my macro to, not only open Access, but to open a specific Access Database and if possible, run
a macro within that database to import the data that I have exported from Excel.

Any ideas?

Thanks





All times are GMT +1. The time now is 02:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com