ACC97: Invalid FileName Causes Untrappable Error In Assistant

Last reviewed: August 29, 1997
Article ID: Q161030
The information in this article applies to:
  • Microsoft Access 97

SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

If you set an invalid FileName property for the Assistant object in Visual Basic for Applications code, a trappable run-time error does not occur until you click Cancel in the message box that appears.

RESOLUTION

You can use the FileSearch object to determine if the Assistant file exists before you set the FileName property in code. The following sample code uses the FileSearch object to search for the Assistant file before you set the FileName property:

  1. Open the sample database Northwind.mdb.

  2. Create a module and type the following procedure:

          Sub SetAssistant(ActFile as String)
             On Error GoTo SetAssistant_Err
             Dim fs As FileSearch
             Dim accObj as Object
             Dim i As Integer
    
             ' Search for the Assistant file name.
             Set fs = Application.FileSearch
             With fs
                .LookIn = "C:\"
                .SearchSubFolders = True
                .FileName = ActFile
                If .Execute > 0 Then
                   Set accObj = CreateObject("Access.Application")
                   With accObj
                      .Visible = True
                      .Assistant.FileName = ActFile
                      .Assistant.Visible = True
                   End With
                Else
                   MsgBox "The Assistant file you specified was not found."
                End If
             End With
             GoTo SetAssistant_Exit
          SetAssistant_Exit:
             Set fs = Nothing
             Set accObj = Nothing
             Exit Sub
          SetAssistant_Err:
             MsgBox Err.Number
             Resume SetAssistant_Exit
          End Sub
    
    

  3. With the module still open in Design view, click References on the Tools menu.

  4. In the References dialog box, click Microsoft Office 8.0 Object Library in the Available References box. If that reference does not appear, click the Browse button and browse your hard drive for MSO97.DLL.

  5. Click OK in the References dialog box.

  6. To test the procedure, type the following line in the Debug window, and then press ENTER:

          SetAssistant("clippit.act")
    

    If Clippit.act exists on your computer, an instance of Microsoft Access starts, shows the Assistant, and then quits. If the file does not exist, you receive an error message and the procedure stops.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Access 97. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

  1. Open the sample database Northwind.mdb.

  2. Create a module and type the following procedure:

          Sub Test()
             On Error GoTo Err_Occurred
             Dim accObj As Object
             Set accObj = CreateObject("Access.Application")
             accObj.Assistant.FileName = "NonExistent.act"
          Exit Sub
    
          Err_Occurred:
          MsgBox "The following error occurred: " & vbcr & Err.Number
    
          End Sub
    
    

  3. To test this function, type the following line in the Debug window, and then press ENTER:

          Test
    

    Note that an instance of Microsoft Access starts, and the Office Assistant displays an error message indicating that the file does not exist. The procedure stops executing until you click Cancel in the Assistant message box. Then the error passes to your error handling code.

REFERENCES

For more information about programming with the Office Assistant, search the Help Index for "Assistant object."


Additional query words: OLE Automation
Keywords : AutoOA kberrmsg IntpOleA
Version : 97
Platform : WINDOWS
Hardware : x86
Issue type : kbbug
Solution Type : kbcode


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.