WinWord: DDEPoke Results Contain Incorrect Character Format

Last reviewed: February 4, 1998
Article ID: Q89527
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b 2.0c, 6.0, 6.0a, 6.0c, 7.0
  • Microsoft Windows operating system versions 3.0, 3.1, and Windows95

SYMPTOMS

When poking, or sending, data to a bookmarked location in a Microsoft Word for Windows document during a DDE conversation, the information may arrive formatted for the incorrect font and size.

STATUS

Microsoft has confirmed this to be a problem in the versions of Microsoft Word for Windows listed above. We are researching this problem and will post more information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

During a DDE conversation with Word for Windows as the server, data can be sent to and extracted from a Word document by referencing a bookmarked location within a document. The document is the topic of the conversation and the bookmarked location is the item.

However, when data is sent, or poked, into a bookmarked location in a Word document, the data may not arrive formatted with the same font and size that the bookmarked location is formatted for. The information should arrive formatted just as though the data were typed at that location manually.

This problem is inconsistent; sometimes the formatting of poked information is correct and sometimes it is incorrect.

WORKAROUND

Because the problem is inconsistent, it is best to add additional commands to your macro to format the text as desired. The following sample selects the poked data then formats it for Arial 20 point, bold and italic:

Note: Menu commands have changed in different versions of Word. Make sure you type in the correct menu commands for the version of Word that you are using.

   Sub MAIN
   chan = DDEInitiate("WINWORD", "Document1")
   DDEPoke chan, "MyBookmark", "Hello World!"

   ' Goto the bookmark location, selecting the text
   cmd$ = "[EditGoTo .Destination = " + Chr$(34) + "MyBookmark" \
   + Chr$(34) + "]"
   DDEExecute chan, cmd$

   ' Format the text with Arial 20, bold and italic
   cmd$ = "[FormatCharacter .Font = " + Chr$(34) + "Arial" \
   + Chr$(34) + ", .Points = " + Chr$(34) + "20" + Chr$(34) \
   + ", .Bold = 1, .Italic = 1]"
   DDEExecute chan, cmd$

   DDETerminate chan
   End Sub

Steps to Reproduce Problem

  1. Launch two instances of Word for Windows (in other words, run two copies of the program on the same computer). In these steps, one instance will communicate with the other.

  2. The first instance of Word for Windows is designated as the client in the DDE conversation. This means it initiates the DDE conversation. Close the default "Document1" and open a document titled something other than "Document1."

  3. From the Tools menu, choose Macro. Type a unique name in the Macro Name box, and choose the Edit button.

  4. In the macro editing window, type the following macro:

          Sub MAIN
          chan = DDEInitiate("WINWORD", "Document1")
          DDEPoke chan, "MyBookmark", "Hello World!"
          DDETerminate chan
          End Sub
    
    

  5. Switch to the other instance of Word for Windows (the server in the DDE conversation) and make sure that the default document ("Document1") is the active document. Press ENTER a few times to create some blank lines.

  6. Select one of the blank lines. From the Format menu, choose Character. Select a different font and a larger point size. Select the bold and italic options and choose the OK button.

  7. Press HOME to position the insertion point at the start of the line. Choose Bookmark from the Insert menu and type "MyBookmark" (without the quotation marks) in the Bookmark Name box. Choose the OK button.

  8. Switch back to the first instance of Word and choose the Start button on the macro testing bar to execute the macro.

Result: The data appears in the second instance of Word but is not formatted with the chosen font or size. The bold and italic formatting may or may not appear.

REFERENCES

"Win 2.x, 3.0: Windows Dynamic Data Exchange (DDE)," Application Note

Kbcategory: kbusage kbmacro KBSubcategory:


Additional query words: winword2 poke 1.0 1.10 1.1a 2.0 2.0a
word6 2.0a-CD 2.0b winword word7 word95 windows95 win95
Version : 1.x 2.x 6.0 6.0a 6.0c 7.0
Platform : WINDOWS


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.