Microsoft KB Archive/134918

= OpenLinks Method Fails When Recorded Macro Is Run =

Article ID: 134918

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 95a
 * Microsoft Excel 5.0c
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 5.0a for Macintosh

-



This article was previously published under Q134918



SYMPTOMS
In the versions of Microsoft Excel listed above, if you insert an OLE object and link to a file, and you then record the process of opening the source file, the resulting macro will not work. When you play back the Visual Basic for Applications macro, you receive the following error message:

Run-time error '1004':

OpenLinks method of Worksheet class failed



RESOLUTION
To create a link that you can update in a macro, do the following:
 * 1) Go to the source document in the source application.
 * 2) Select the information you want to bring to Microsoft Excel and click Copy on the Edit menu.
 * 3) Open the Microsoft Excel workbook in which you want this information to appear.
 * 4) Select the cell where you want this information to begin.
 * 5) Click Paste Special on the Edit menu.
 * 6) In the Paste Special Dialog box, click Paste Link, and then click Document Object.
 * 7) Click OK.

The object will appear.

If you then turn on the macro recorder and double-click the object to open the source document, the resulting macro will work.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition. For additional information, please see the following article in the Microsoft Knowledge Base:

115693 "Incorrect Argument Recorded with OpenLinks Method"

