ACC: OLE Automation Error Using Insert Method into MS Word

Last reviewed: August 29, 1997
Article ID: Q132130
The information in this article applies to:
  • Microsoft Access versions 2.0, 7.0

SYMPTOMS

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

In OLE Automation, when you use the Insert method to insert text into a Microsoft Word for Windows document, you may receive the following error message:

   In Microsoft Access version 7.0:

      Invalid Use of Null

   In Microsoft Access version 2.0:

      The object cannot convert one of the arguments passed to the member.

CAUSE

You are passing a null value from Microsoft Access to the OLE Server application.

RESOLUTION

In the event procedure or a custom function, add code to verify that the value sent to the OLE Server is not a null. For example, you can add the following code:

   If Not IsNull(Forms![MyForm]![MyControl) Then
      WordObj.Insert Forms![MyForm]![MyControl]
   EndIf

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open an existing Microsoft Access database.

  2. Create a new, blank form and save the form as MyForm.

  3. Add a text box to the form and set the text box's Name property to MyControl.

  4. Add a command button to the form and set the command button's Name property to MyButton.

  5. Set the MyButton command button's OnClick property to the following event procedure:

          Dim WordObj as Object
          Set WordObj=CreateObject("Word.Basic")
          WordObj.FileNew
          WordObj.Insert CStr(Forms![MyForm]![MyControl])
    

  6. View the MyForm form in Form View. Leave the text box empty and click the MyButton command button. Note that you receive the error message described in the "Symptoms" section.

REFERENCES

For more information about working with other applications using OLE automation, search for "Working Across Applications" using the Microsoft Access for Windows 95 Help Index.

Microsoft Access "Building Applications," version 2.0, Chapter 13, "Communicating with Other Applications," pages 281-297

Keywords          : AutoGnrl kberrmsg kbole IntpOleA
Technology        : kbole
Version           : 2.0 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbprb
Solution Type     : Info_Provided


================================================================================


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.