Results 1 to 16 of 16

Thread: [RESOLVED] Testing for an instance of word

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    131

    Resolved [RESOLVED] Testing for an instance of word

    Hi RobDog,

    I am having the exact same issue with my code. I get the "ActiveX component can't create object" error even with the On Error Resume Next code. How can I get around this? All I want to do is test for an instance of Access and if Access is open, close it. I am trying to avoid the exclusive lock error that occurs if the database I am ADO Connecting to is already open. Here is the beginning part of my code that contains the line of error (the line in which the error occurs is in red):

    VB Code:
    1. Private Sub UserForm_Initialize()
    2. ' Opens an ADO Connection to Issues Database and fills in arInfo fields with
    3. ' values from the database (ie Contacts, Categories, Status, etc).  This is _
    4. ' needed because the values from the DB are dynamic and can be changed by the user.
    5. ' This function should only be called 1 time when the "Add to AR Tracker" menu
    6. ' item is clicked, even if there are multiple selections in the ActiveExplorer.
    7. On Error Resume Next
    8.  
    9.     Dim CnnA As ADODB.Connection
    10.     Dim statusRS As ADODB.Recordset
    11.     Dim priorityRS As ADODB.Recordset
    12.     Dim categoryRS As ADODB.Recordset
    13.     Dim assignedToRS As ADODB.Recordset
    14.     Dim aApp As Access.Application
    15.  
    16.     Set CnnA = New ADODB.Connection
    17.     Set statusRS = New ADODB.Recordset
    18.     Set priorityRS = New ADODB.Recordset
    19.     Set categoryRS = New ADODB.Recordset
    20.     Set assignedToRS = New ADODB.Recordset
    21.     [COLOR=Red]Set aApp = GetObject(, "Access.Application")[/COLOR]
    22.    
    23.     If TypeName(aApp) <> "Nothing" Then
    24.         'An Access instance is running
    25.         If MsgBox("Outlook must close your AR Tracker database in order to perform the requested action." _
    26.         & vbCr & "Do you want to Outlook to close your AR Tracker?", vbYesNo, "Close AR Tracker?") = vbYes Then
    27.             aApp.Quit
    28.         Else: GoTo End_Sub
    29.         End If
    30.     End If
    Last edited by RobDog888; Apr 27th, 2006 at 01:58 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width