rci was telling us:
rci nous racontait que :
> Hi all,
>
[quoted text clipped - 4 lines]
>
> What the heck!
My macro recorder recorded everything without any problems:
'_______________________________________
Sub Macro1()
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 126#, _
108#, 342#, 198#).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.TypeText Text:= _
"I have created this textbox and typed this text while the macro
recorder was on."
Selection.TypeParagraph
Selection.TypeText Text:= _
"Now I am going to select this box, cut it, type some text in the main
document and paste the box back in."
Selection.ShapeRange.Select
Selection.Cut
Selection.TypeText Text:="Text in the main document."
Selection.TypeParagraph
Selection.Paste
End Sub
'_______________________________________
> Excel does an excellent job of same.
So does Word!
> Q: Are drawing objects even supported by Word VBA?
Yes.
> Specific issue: I need to add and change the text in a text box, as
> well as paste/move an object.
>
> Any help appreciated!
Here is the same macro, rewritten to remove the Selection object as much as
possible.
'_______________________________________
Sub MacroReWorked()
Dim MyBox As Shape
Dim BoxText As Range
With ActiveDocument
Set MyBox = .Shapes.AddTextbox(msoTextOrientationHorizontal, _
126#, 108#, 342#, 198#)
With MyBox
Set BoxText = .TextFrame.TextRange
BoxText.Text = "I have created this textbox and typed this text " _
& " while the macro recorder was on." & Chr(13) _
& "Now I am going to select this box, cut it, type some text " _
& "in the main document and paste the box back in."
.Select
End With
Selection.Cut
.Paragraphs(1).Range.Text = "Text in the main document." & Chr(13)
Selection.Paste
End With
End Sub
'_______________________________________

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org