Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word InlineShape CommandButton

Status
Not open for further replies.

bigoldbulldog

Programmer
Feb 26, 2002
286
US
Hello -

Does anyone have a decent way to move, ie. cut and paste, a command button in MS Word? I've only come up with very clunky strategies.

This text layer button comes from
Selection.InlineShapes.AddOLEControl _
ClassType:="Forms.CommandButton.1"

Thanks,
ND
 
I'll answer my own question. I found there is no way to move or re-dimension an InlineShape object. I may not be hidden either. Conversion to a Shape object kind of helps but behaves oddly and can't be moved and converted by to InlineShape. I also found looping throught the collection of InlineShapes to delete a particular one - by name or Caption seems to fail 60% of the time.

Solution:
To actually move it is easiest to delete the button and re-create where desired. I deleted successfully by converting the InlineShape to Shape and using Delete. I saved the important attributes before deleting such as fonts,dimensions,Caption and name. Then I use select to obtain the new location and recreate the button. Then I replace the desired fields. The nice thing is that using the old name again the CommandButton_Click command which is called <Button name>_Click will immediately correspond to the newly made button.

Selection.MoveDown unit:=wdLine, Count:=3
Set myCB = ActiveDocument.InlineShapes. _
AddOLEControl(ClassType:=&quot;Forms.CommandButton.1&quot;, Range:=Selection.Range)

With myCB.OLEFormat.Object
.Caption = &quot;Add Another DVG&quot;
.name = &quot;CopyDVGButton&quot;
.width = 100
With .Font
.name = &quot;Arial&quot;
.Size = 10
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
End With
End With

And life is good.
ND
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top