PRB: Strings w/ TABs Sent from VB to Excel via DDE Are ChoppedLast reviewed: June 21, 1995Article ID: Q82157 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0- Microsoft Visual Basic programming system for Windows, version 1.0
SYMPTOMSUnexpected behavior may occur in a dynamic data exchange (DDE) conversation from Visual Basic to Microsoft Excel when you send a string that contains TAB characters. If you specified a specific row and column in the Visual Basic LinkItem property, the string may be truncated in Excel. If you didn't specify a column in the LinkItem property but only specified a specific row, the string will be parsed by Excel, and each TAB will cause the characters following the TAB to be entered into the following cell in Excel.
CAUSEThe reason for this behavior is that Excel uses TABs as its delimiter. You can use this method to send multiple items to Excel, placing them in their own cells if desired.
RESOLUTIONEither don't send strings that contain TABs or else provide more complete information in the LinkTopic property. For example, in the code shown in the "Steps to Reproduce Behavior" section below, you can work around the undesired behavior by placing the following value in the ListTopic property:
DDEbox.LinkTopic = "R" + Row$ + "C1:R" + Row$ + "C2"By specifying a larger selection of cells, you can ensure that the data being passed will not be truncated and that the embedded TAB, RETURN, or LINEFEED characters will be interpreted correctly as the next column or next row.
STATUSThis behavior is by design.
MORE INFORMATIONThis behavior occurs when the following is true:
"The cow jumped" + Chr$(9) + "over the moon"the only thing you will see on the Excel side is "The cow jumped." The rest of the string will be lost.
Steps to Reproduce BehaviorThe following example passes strings to Excel from a list box that has TAB- delimited columns. Run the program twice, and change the LinkItem line from a comment into an executed line of code, and observe the different behavior.
hey ' This will be in cell A1. for ' This will be in cell A2. If you change the assignment statement of the LinkItem of the DDEbox from:
DDEbox.LinkItem = "R" + Row$ + "C1"to:
DDEbox.LinkItem = "R"+ Row$the entire string is passed to Excel with the following results:
hey is ' These words will be in A1 and B1. for horses ' These words will be in A2 and B2. |
Additional reference words: 1.00 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |