XL98: Run-Time Error When Using DDEInitiate with Word

Last reviewed: February 4, 1998
Article ID: Q177000
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

When you run a Microsoft Visual Basic for Applications macro that uses the DDEInitiate command to launch Microsoft Word, you may receive the following error message:

   Run-time error '-2147352571 (80020005)':

   Cannot find data source.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

If you want to programmatically control Word from Excel with a Visual Basic macro, use Automation instead of dynamic data exchange (DDE). The following example illustrates using Automation to start Word and print a file in Word from an Excel macro.

  1. Create a new file in Word. Save the file to the hard drive with the name "Automation" (without the quotation marks).

  2. Quit Word.

  3. Start Excel.

  4. Start the Visual Basic Editor (press OPTION+F11).

  5. On the Insert menu, click Module.

  6. On the Tools menu, click References. Click the "Microsoft Word 8.0 Object Library" check box, and then click OK.

  7. Type the following code into the module sheet:

          Sub Automation_to_Word
    
             Dim WordDoc as Word.Application
    
             ' Start Word.
             Set WordDoc = CreateObject("Word.Application.8")
    
             ' Open the document that was created in Step 1. You must supply
             ' the correct path to the document for the FileName argument.
             WordDoc.Documents.Open FileName:="Mac HD:Automation"
    
             ' Print the document.
             WordDoc.application.PrintOut Range:=wdPrintAllDocument, _
                Item:=wdPrintDocumentContent, _
                Copies:=1, PageType:=wdPrintAllPages
    
             ' Close the document.
             WordDoc.Documents("Automation").Close
    
             ' Quit Word.
             WordDoc.Quit
    
             ' Release the memory used by the variable.
             Set WordDoc = Nothing
    
          End Sub
    
    

  8. Run the macro.

The macro starts Word, opens the document that you created in Step 1, prints the document, and then quits Word.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

For more information about Automation, click the Office Assistant, type "automation," click Search, and then click to view "Understanding Automation."

For more information about Automation, click the Office Assistant, type "automation," click Search, and then click to view "Controlling One Microsoft Office Application from Another."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Excel Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office
               Program or Component


Additional query words: XL98
Keywords : kbcode kbprg IntpOleA
Technology : ole
Version : MACINTOSH:98
Platform : MACINTOSH
Hardware : MAC
Issue type : kbbug
Solution Type : kbworkaround


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: February 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.