vba object names in word

N

Neil H

Hello,

I'm new to using vba in word, but I'm quite familiar with using VBA
for access and thought it'd be quite straightforward. However I'm
struggling right away. I'm trying to reference a piece of word art -
to turn it on and off. How on earth do I reference it?

Through google searches I've discovered I can reference is by doing
something like ActiveDocument.Shapes(1) or something and hoping to hit
the right number... but I'd like to understand how to access the
actual name of the wordart object itself so I can reference it
properly. How do i find it? Is there a way of seeing it somehow?

I'm puzzled...

With thanks,
Neil
 
H

Helmut Weber

Hi Neil,

like this:

Sub Macro12()
Dim oshp As Shape
Set oshp = ActiveDocument.Shapes.AddTextEffect _
(msoTextEffect3, "Your Text Here", _
"Arial Black", 36#, msoFalse, msoFalse, 150, 150)
oshp.Name = "Yes"

' --------------------------------------------------

End Sub
Sub Macro13()
MsgBox ActiveDocument.Shapes("Yes").Height
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
P

Perry

No out-of-the-box, suitable property you can use for that purpose.

Work-around:
You could try using the AlternativeText property of objects in Word
documents.
Use this property to maintain (free) text tied to the object.
Looping through the objects and read out this property will give you what
you need.

Implications:
you will have to make and enforce a deal with the template
coordinator/owner/administrator to maintain:
- unique naming convention
- clear/identifyable naming

If this is achieved, you can think of functional prefixing ...etc

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 

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