PDA

Click to See Complete Forum and Search --> : How to Change


spyder
Jan 19th, 2000, 03:24 AM
How do you change the properties of a command button... Checkbox... in a VBA app that these items are Dynamically created.

Example:
User opend doc, selects this type and VBA creates next from based on the previous information

This is in MSWord if it helps any,

Code that I have so far:
Selection.InlineShapes.AddOLEControl ClassType:="Forms.CommandButton.1"

This Creates the Object in the document, How can I change the caption on the Button?

netSurfer
Jan 19th, 2000, 03:39 AM
I beleive all the VBA is the same therefore:

CommandButton1.setfocus
CommandButton1.caption = "New Caption"

you have to have the name of the command button, then you set focus to it and rename the caption.

spyder
Jan 19th, 2000, 03:45 AM
I wish it was that simple, I did try that and I the get and object required error 424

Any other Ideas?

LG
Jan 19th, 2000, 08:24 AM
Hi, Spyder.

Try this:

Dim myCB As Object
Set myCB = ActiveDocument.Shapes.AddOLEControl(ClassType:="Forms.CommandButton.1")
With myCB.OLEFormat.Object

.Caption = "Check if over 21"
End With

Larisa

spyder
Jan 20th, 2000, 01:00 AM
Thanks, It worked