The information in this article applies to:
SYMPTOMS
In Microsoft Word, when you create a macro to select adjacent text from
left to right and then assign the selections to two different variables, if
you then set the first variable to be equal to the value of the second
variable, you may receive unexpected results. Specifically, the value of
the second variable will be twice as many words as what you expect.
Sample Macro
If you run this macro, the message box shows that the second variable
oSelection2 takes the value "testing testing." This is an order and
position issue: if you select word three and then word two, or if you
select word two and then word four, this problem will not occur.
CAUSE
This behavior is by design of Microsoft Word. If you have a selection, and
if you insert text to the left of the first character, that text becomes
part of the selection. To see how Word adjusts selections, follow these
steps:
REFERENCESFor more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base: Q163435 VBA: Programming Resources for Visual Basic for Applications Additional query words:
Keywords : kbdta WordCon kbmacroexample kbwordvba KbVBA |
Last Reviewed: October 21, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |