Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511

    Unanswered: Is Access Application Running

    I would like to know how to test in Excel VBA if Access is running. My Excel applications opens Access, so I plan to tell the user to close Access before using the Excel application.

    Thanks.
    Jerry

  2. #2
    Join Date
    Oct 2003
    Posts
    1,091
    Howdy, Jerry.

    Code:
    Sub MyStartAccess()
        AppFile = "MSACCESS.EXE"
        On Error Resume Next
        AppActivate "Access"
        If Err <> 0 Then
            Err = 0
                AccessTaskID = Shell(AppFile, 1)
                If Err <> 0 Then
                    MsgBox "Can't start Access"
                End If
        End If
    End Sub
    This will check whether it is open, if not, it will open an instance of Access.

    Is this what you needed?
    old, slow, and confused
    but at least I'm inconsistent!

    Rich
    (retired Excel 2003 user, 3/28/2008)

    How to ask a question on forums

  3. #3
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    Thanks Shades. I tried out your solution and it works as you stated. The solution I am using was found in a book, and an exact copy is shown below. I modified it to prompt the user, and if the user clicks OK, all Access sessions are closed before for proceeding to use the application, which opens Access from Excel.

    HTML Code:
    Function IsRunning(ByVal myAppl As String) As Boolean
        Dim applRef As Object
        On Error Resume Next
       
        Set applRef = GetObject(, myAppl)
        If Err.Number = 429 Then
              IsRunning = False
        Else
              IsRunning = True
        End If
        ' clear object variable
        Set applRef = Nothing
    End Function
    Jerry

Posting Permissions

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