+ Reply to Thread
Results 1 to 4 of 4

Opening Access without declaring a Global Object?

  1. #1
    Joel.R.Hill@gmail.com
    Guest

    Opening Access without declaring a Global Object?

    So I've encountered an error that many others have come across, but
    there still doesn't seem to be a clear solution. I am trying to open
    MS Access via an Excel macro and import a spreadsheet. This creates an
    underlying EXCEL.EXE due to a global object being stored in the memory,
    but I'm unsure how to alleviate this error. Any help/ideas would be
    much appreciated. The below is the Excel macro that is opening MS
    Access:

    Sub OpenAccess()
    Dim oApp As Object
    Set oApp = CreateObject("Access.Application")
    oApp.Visible = True
    oApp.OpenCurrentDatabase "C:\Test.mdb"
    Set oApp = Nothing
    End Sub


  2. #2
    NickHK
    Guest

    Re: Opening Access without declaring a Global Object?

    Joel,
    Not sure I see the problem with Excel.
    Explain a bit more.

    NickHK

    <Joel.R.Hill@gmail.com> wrote in message
    news:1156205650.320888.232910@m79g2000cwm.googlegroups.com...
    > So I've encountered an error that many others have come across, but
    > there still doesn't seem to be a clear solution. I am trying to open
    > MS Access via an Excel macro and import a spreadsheet. This creates an
    > underlying EXCEL.EXE due to a global object being stored in the memory,
    > but I'm unsure how to alleviate this error. Any help/ideas would be
    > much appreciated. The below is the Excel macro that is opening MS
    > Access:
    >
    > Sub OpenAccess()
    > Dim oApp As Object
    > Set oApp = CreateObject("Access.Application")
    > oApp.Visible = True
    > oApp.OpenCurrentDatabase "C:\Test.mdb"
    > Set oApp = Nothing
    > End Sub
    >




  3. #3
    Unowho13
    Guest

    Re: Opening Access without declaring a Global Object?

    Hi Nick,

    This issue occurs if you create a mdb that has an import macro; once
    the Access import macro runs after the Excel macro, it creates another
    EXCEL.EXE instance. Use the following steps to replicate the error...
    Assume you have the following Excel spreadsheet + the code listed
    below:

    ColA ColB
    CarType Make
    Ford Mustang
    Chevy Impala

    1) Create an Access database with a table + an import macro pointing
    at the spreadsheet described above
    2) Save + Close the mdb
    3) Use the Excel code below to open the mdb
    4) Run the Access import macro
    5) Close the mdb
    6) Close the Excel App
    7) Go to the task manager; you will notice the EXCEL.EXE is still
    present even though the physical Excel App has been closed.

    hope this clarifies...


    NickkHK wrote:
    > Joel,
    > Not sure I see the problem with Excel.
    > Explain a bit more.
    >
    > NickHK
    >
    > <Joel.R.Hill@gmail.com> wrote in message
    > news:1156205650.320888.232910@m79g2000cwm.googlegroups.com...
    > > So I've encountered an error that many others have come across, but
    > > there still doesn't seem to be a clear solution. I am trying to open
    > > MS Access via an Excel macro and import a spreadsheet. This creates an
    > > underlying EXCEL.EXE due to a global object being stored in the memory,
    > > but I'm unsure how to alleviate this error. Any help/ideas would be
    > > much appreciated. The below is the Excel macro that is opening MS
    > > Access:
    > >
    > > Sub OpenAccess()
    > > Dim oApp As Object
    > > Set oApp = CreateObject("Access.Application")
    > > oApp.Visible = True
    > > oApp.OpenCurrentDatabase "C:\Test.mdb"
    > > Set oApp = Nothing
    > > End Sub
    > >



  4. #4
    NickHK
    Guest

    Re: Opening Access without declaring a Global Object?

    Running you code below results in Access starting and the mdb opening, then
    all closing/quitting.
    OK, there's no import routine running, but as such that is Access code
    problem, not Excel.

    I assume there is some kind of auto run macro in the .mdb to do the import.
    But as you creating an instance of Access, why not control the import from
    the Excel macro. Then .Quit Access when finished.

    NickHK

    "Unowho13" <Joel.R.Hill@gmail.com> wrote in message
    news:1156294002.942175.41140@75g2000cwc.googlegroups.com...
    > Hi Nick,
    >
    > This issue occurs if you create a mdb that has an import macro; once
    > the Access import macro runs after the Excel macro, it creates another
    > EXCEL.EXE instance. Use the following steps to replicate the error...
    > Assume you have the following Excel spreadsheet + the code listed
    > below:
    >
    > ColA ColB
    > CarType Make
    > Ford Mustang
    > Chevy Impala
    >
    > 1) Create an Access database with a table + an import macro pointing
    > at the spreadsheet described above
    > 2) Save + Close the mdb
    > 3) Use the Excel code below to open the mdb
    > 4) Run the Access import macro
    > 5) Close the mdb
    > 6) Close the Excel App
    > 7) Go to the task manager; you will notice the EXCEL.EXE is still
    > present even though the physical Excel App has been closed.
    >
    > hope this clarifies...
    >
    >
    > NickkHK wrote:
    > > Joel,
    > > Not sure I see the problem with Excel.
    > > Explain a bit more.
    > >
    > > NickHK
    > >
    > > <Joel.R.Hill@gmail.com> wrote in message
    > > news:1156205650.320888.232910@m79g2000cwm.googlegroups.com...
    > > > So I've encountered an error that many others have come across, but
    > > > there still doesn't seem to be a clear solution. I am trying to open
    > > > MS Access via an Excel macro and import a spreadsheet. This creates

    an
    > > > underlying EXCEL.EXE due to a global object being stored in the

    memory,
    > > > but I'm unsure how to alleviate this error. Any help/ideas would be
    > > > much appreciated. The below is the Excel macro that is opening MS
    > > > Access:
    > > >
    > > > Sub OpenAccess()
    > > > Dim oApp As Object
    > > > Set oApp = CreateObject("Access.Application")
    > > > oApp.Visible = True
    > > > oApp.OpenCurrentDatabase "C:\Test.mdb"
    > > > Set oApp = Nothing
    > > > End Sub
    > > >

    >




+ 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