PDA

View Full Version : Overtype in macros



andalusia
01-24-2007, 03:00 PM
It is possible to turn on Overtype programmatically:


Options.Overtype = True


However,


Selection.TypeText("Hello World!")


ignores this overtype mode and types out in insert mode.

Is there a way to make macros respect the Overtype mode?

Bob Phillips
01-24-2007, 04:57 PM
Works for me as long as charcaters are selected, as does



Options.ReplaceSelection = True
Selection.TypeText ("hello world")

TonyJollans
01-24-2007, 05:46 PM
Interesting. The Help for TypeText says "Inserts the specified text" (my emphasis). Nonetheless I would call that a bug - TypeText should work as though the text had been typed and, clearly, it doesn't.

andalusia
01-25-2007, 04:46 PM
Works for me as long as charcaters are selected, as does



Options.ReplaceSelection = True
Selection.TypeText ("hello world")



However, replacement is different from overtype. In replacement, the selected characters are always erased, and the typed text is inserted. With overtype, if n characters are typed, n characters are replaced, with some exception, such as if you go to a new blank line. To clarify, I will use the symbol "^" to represent the selection point, with a range specified by two surrounding "^" symbols.



Under replacement:

The quick brown fox jumped over the ^lazy^ dog.
Selection.TypeText("flea-bitten")
produces
The quick brown fox jumped over the flea-bitten dog.




Under overtype:

The quick brown fox jumped over the ^lazy dog.
typing in overtype mode
flea-bitten
produces
The quick brown fox jumped over the flea-bitten



It is a subtle difference, but the main result that I am achieving is that overtype results in the same amount of space being taken up by typed material, so that overtype can be used to replace material without changing general page style appearance.