If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Is Access Application Running

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-08-06, 19:49
JerryDal JerryDal is offline
Registered User
 
Join Date: Jan 2002
Location: Bay Area
Posts: 473
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
Reply With Quote
  #2 (permalink)  
Old 12-13-06, 14:41
shades shades is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 12-13-06, 15:39
JerryDal JerryDal is offline
Registered User
 
Join Date: Jan 2002
Location: Bay Area
Posts: 473
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On