MacXL: Run-Time Error When Using DDEInitiate with Word (177000)
The information in this article applies to:
- Microsoft Excel 2001 for Mac
- Microsoft Excel 98 Macintosh Edition
This article was previously published under Q177000 SYMPTOMS
When you run a Microsoft Visual Basic for Applications macro that uses the
DDEInitiate command to start Microsoft Word, you may receive the following
error message:
Run-time error '-2147352571 (80020005)':
Cannot find data source.
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements.
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 for Excel 98 illustrates how to use Automation to start Word and print a file in Word from an Excel macro.
- Create a new file in Word. Save the file to the hard disk, and name the file Automation.
- Quit Word.
- Start Excel.
- Start the Visual Basic Editor (press OPTION+F11).
- On the Insert menu, click Module.
- On the Tools menu, click References. Click to select the "Microsoft Word 8.0 Object Library" check box, and then click OK.
- 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
- Run the macro.
The macro starts Word, opens the document that you created in step 1,
prints the document, and then quits Word.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. REFERENCESFor more information about Automation, in the Visual Basic Editor, click the Office Assistant, type understanding automation, click Search, and then click a topic to view it.
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar.
In Excel 98, click the Office Assistant, type automation, click Search, and then click to view "Controlling One Microsoft Office Application from Another."
Modification Type: | Major | Last Reviewed: | 6/17/2005 |
---|
Keywords: | kbbug kbcode kbProgramming KB177000 |
---|
|