+ Reply to Thread
Results 1 to 2 of 2

Macro doesn't stop running

  1. #1
    Registered User
    Join Date
    04-14-2005
    Posts
    10

    Macro doesn't stop running

    This macro used to work fine. Untill i tried this on my new computer. Now it stucks somehow.

    This is my problem:
    The information in my excelsheet is to be exported to an access database by the click on a button.

    This is the macro that should do it:

    Sub GetAccess()
    Application.StatusBar = "Working in MS Access"
    Dim MyAccess As Object
    Set MyAccess = CreateObject("Access.Application")
    MyAccess.OpenCurrentDatabase ActiveWorkbook.Path & "\database.mdb"
    MyAccess.DoCmd.RunMacro "Run"
    MyAccess.Quit
    End Sub


    Now when i enter stuff in the excelsheet, and i press the button to export it, i see "working in MS Access" appear on the bottom of the screen. The information is indeed exported.

    The problem is, when i try this a second time, it doesn't work anymore. the "working in MS Access" doesn't dissapear from the bottom. The macro seems to not stop working after a first click on the button.

    Even when i close the excellist, i get a message saying "the file is now available for editing" or something.

    Does anyone have an idea what has caused this?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Nogi,

    One thing I noticed about your macro, you don't release the object reference after executing MyAccess.Quit. Try adding Set MyAccess = Nothing to release the object. If you don't you risk creating a "shadow" object, one the system sees but you can't reference.

    Hope this helps,
    Leith Ross

+ 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