Group: microsoft.public.word.vba.general
From: =?Utf-8?B?Tm9ydGggV2FsZXM=?=
Date: Sunday, January 27, 2008 1:03 PM
Subject: Re: Macros

Hi,
Thanks to both of you for your help, will use next week.
--
Rich...




"Greg Maxey" wrote:

> To add to what Lene said, it can get difficult pretty quick trying to find
> the index of a shape.
>
> Shapes have names. You can either select the shape and get the name or
> select the shape and give it your own name:
>
> Sub Test()
> MsgBox Selection.ShapeRange.Name
> 'Or give it your own name
> Selection.ShapeRange.Name = "My niffty little text box 1"
> End Sub
>
> Now that you know the shape name you can use code like this:
>
> Sub SelectItem()
> ActiveDocument.Shapes("My niffty little text box 1").Select
> 'To select the second table in your textbox
> ActiveDocument.Shapes("My niffty little text box
> 1").TextFrame.TextRange.Tables(2).Select
> 'To select the cell at the first row and first columnn
> ActiveDocument.Shapes("My niffty little text box
> 1").TextFrame.TextRange.Tables(2).Cell(1, 1).Range.Select
> End Sub
>
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
>
> Lene Fredborg wrote:
> > Some examples that might help you:
> >
> > Text boxes:
> > In VBA terms, a text box is a shape. The following code checks
> > whether the third shape in the active document is a text box. If that
> > is the case, the shape is selected. Note that the most recently
> > created shape has the highest index number, i.e. it is not the
> > position in the document that determines the number.
> >
> > With ActiveDocument
> > If .Shapes(3).Type = msoTextBox Then
> > .Shapes(3).Select
> > End If
> > End With
> >
> > Tables:
> > The following code selects the second table in the document:
> > ActiveDocument.Tables(2).Select
> >
> > The following code selects the entire table in which the selection is
> > currently found:
> > Selection.Tables(1).Select
> >
> >
> >> Hi,
> >>
> >> How do I use a macro to select a text box and how can I do the
> >> same but select a table?
> >>
> >>
> >> Rich.
>
>
>

Safety Articles | Usenet Groups | Usenet News | Bluegrass