How are objects identified for VBA?

M

mcwhirt3

In excel i use vba to control objects(wordart, boxes, lines...etc.)
However in excel it is clear what each object's "name" is in that
dialog box in the toolbar, so that you may refrence it in code. In
Publisher I basically want to have a userform with a tetxbox that dumps
it's contents into a textbox on a poster template in publisher. I just
don't know what to do for the "controlsource" property of the textbox.
I've tried generically assigning it to "textbox1" but that doesn't seem
to work. How do i relate code to objects if i don't know what the name
of the object is? Thanks for any help.
 
E

Ed Bennett

In excel i use vba to control objects(wordart, boxes, lines...etc.)
However in excel it is clear what each object's "name" is in that
dialog box in the toolbar, so that you may refrence it in code. In
Publisher I basically want to have a userform with a tetxbox that
dumps it's contents into a textbox on a poster template in publisher.
I just don't know what to do for the "controlsource" property of the
textbox. I've tried generically assigning it to "textbox1" but that
doesn't seem to work. How do i relate code to objects if i don't know
what the name of the object is? Thanks for any help.

I haven't programmed against Excel or Word, so I'm not really sure what the
big differences are, but in Publisher you reference a shape as follows
<Document Object such as ActiveDocument>.Pages(pageid).Shapes(shapeid)

I tend to either create shapes at runtime so I can assign them to objects
and keep them in check that way, or I use the selection
Selection.ShapeRange(1) returns the first selected object (I tend to make
sure there is only one object selected to simplify things)
Selection.TextRange returns the selected text range if text within a text
box is selected.

If you haven't already done so, check out the VBA help files at c:\Program
Files\Microsoft Office\Office11\1033\VBAPB10.CHM (default location, will
vary with language and install folder)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top