Microsoft KB Archive/89527

{|
 * width="100%"|

WinWord: DDEPoke Results Contain Incorrect Character Format

 * }

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
 * Microsoft Word for Windows 95, version 7.0
 * Microsoft Windows versions 3.0, 3.1
 * Microsoft Windows 95

-

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(&quot;WINWORD&quot;, &quot;Document1&quot;) DDEPoke chan, &quot;MyBookmark&quot;, &quot;Hello World!&quot;

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

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

DDETerminate chan End Sub

Steps to Reproduce Problem
 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. 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 &quot;Document1&quot; and open a document titled something other than &quot;Document1.&quot; From the Tools menu, choose Macro. Type a unique name in the Macro Name box, and choose the Edit button.  In the macro editing window, type the following macro:      Sub MAIN chan = DDEInitiate(&quot;WINWORD&quot;, &quot;Document1&quot;) DDEPoke chan, &quot;MyBookmark&quot;, &quot;Hello World!&quot; DDETerminate chan End Sub  Switch to the other instance of Word for Windows (the server in the DDE conversation) and make sure that the default document (&quot;Document1&quot;) is the active document. Press ENTER a few times to create some blank lines. 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. Press HOME to position the insertion point at the start of the line. Choose Bookmark from the Insert menu and type MyBookmark in the Bookmark Name box. Choose the OK button.</li> Switch back to the first instance of Word and choose the Start button on the macro testing bar to execute the macro.</li></ol>

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.