+ Reply to Thread
Results 1 to 5 of 5

Can you open Access Database through Excel VBA?

  1. #1
    dj
    Guest

    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!

  2. #2
    XP
    Guest

    RE: 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!


  3. #3
    dj
    Guest

    RE: 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!


  4. #4
    Registered User
    Join Date
    11-12-2005
    Posts
    55

    Arrow open access database in excel

    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

  5. #5
    Don Wiss
    Guest

    Re: Can you open Access Database through Excel VBA?

    On Mon, 8 May 2006 16:41:00 -0500, amrezzat
    <[email protected]> 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).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1