Microsoft KB Archive/132130

= ACC: OLE Automation Error Using Insert Method into MS Word =

Article ID: 132130

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q132130



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



Steps to Reproduce Behavior
 Open an existing Microsoft Access database. Create a new, blank form and save the form as MyForm. Add a text box to the form and set the text box's Name property to MyControl. Add a command button to the form and set the command button's Name property to MyButton.  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])  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.</li></ol>

<div class="references_section">