![]() |
Can you open Access Database through Excel VBA?
Hello,
I am writing an excel macro that would do various things, and at the end I would like for it to open up an Access Database. This database would then run an autoexec macro and print reports. Is it possible to write code in VBA to open an Access Database? And what would the line of code be to do this? Any help is much appreciated! THANKS! |
Can you open Access Database through Excel VBA?
One way:
Copy the following function into a standard code module and call like so: Sub TestLoad() 'your code Call AccessLoadApplication 'your other code end sub Public Function AccessLoadApplication() 'LOAD ACCESS APPLICATION Static appXS As Object Set appXS = CreateObject("Access.Application") appXS.Visible = True End Function HTH "dj" wrote: Hello, I am writing an excel macro that would do various things, and at the end I would like for it to open up an Access Database. This database would then run an autoexec macro and print reports. Is it possible to write code in VBA to open an Access Database? And what would the line of code be to do this? Any help is much appreciated! THANKS! |
Can you open Access Database through Excel VBA?
THANKS!!!
"XP" wrote: One way: Copy the following function into a standard code module and call like so: Sub TestLoad() 'your code Call AccessLoadApplication 'your other code end sub Public Function AccessLoadApplication() 'LOAD ACCESS APPLICATION Static appXS As Object Set appXS = CreateObject("Access.Application") appXS.Visible = True End Function HTH "dj" wrote: Hello, I am writing an excel macro that would do various things, and at the end I would like for it to open up an Access Database. This database would then run an autoexec macro and print reports. Is it possible to write code in VBA to open an Access Database? And what would the line of code be to do this? Any help is much appreciated! THANKS! |
Can you open Access Database through Excel VBA?
Dim dbnorthwind As DAO.Database Dim dpath As String dbpath = "C:\Program Files\Microsoft Office\OFFICE11\sAMPLES\northwind.mdb" Set dbnorthwind = OpenDatabase(dbpath) Dim rseployees As DAO.Recordset Dim rscustomers As DAO.Recordset Set rseployees = dbnorthwind.OpenRecordset("employees", dbOpenTable) Set rscustomers = dbnorthwind.OpenRecordset("customers", dbOpenTable) i = 2 With rseployees If Not .EOF Then .MoveFirst Do While Not .EOF Cells(i, 1).Value = .Fields(2) Cells(i, 2).Value = .Fields(1) MoveNext i = i + 1 Loop End With -- amrezzat ------------------------------------------------------------------------ amrezzat's Profile: http://www.excelforum.com/member.php...o&userid=28766 View this thread: http://www.excelforum.com/showthread...hreadid=540002 |
Can you open Access Database through Excel VBA?
On Mon, 8 May 2006 16:41:00 -0500, amrezzat
wrote: Set dbnorthwind = OpenDatabase(dbpath) You will also need to set a VBA Tools - References... to Microsoft DAO 3.6 Object Library. Don <www.donwiss.com (e-mail link at home page bottom). |
All times are GMT +1. The time now is 11:31 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com