p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

vba_word thread: querying the shapes in section

Message #1 by dtudose@y... on Sat, 8 Jun 2002 16:22:19
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


if I understood your problem correctly 
what you want is to get values for the top and height of all type-9 shape
s in the last sections

for that your code should be as follows:


For i =3D 1 To ActiveDocument.Sections.Item(ActiveDocument.Sections.Count

    If Application.ActiveDocument.Sections.Item(ActiveDocument.Sections.C
ount).Range.ShapeRange(i).Type =3D 9 Then

        auxiliar =3D Application.ActiveDocument.Sections.Item(ActiveDocum

        If auxiliar > margineaDeJos Then

            lungimeSageata =3D Application.ActiveDocument.Sections.Item(A

           margineaDeJos =3D auxiliar

        End If

    End If

Next i

Here ActiveDocument.Sections.Count will give you the count of last sectio
n and 
variable 'i' will give the count of the shapes in the last section

If you want to perform the same task for all the sections just include th
e above code in an outer loop
such as

For j =3D1 To ActiveDocument.Sections.Count 

.............add above code here..........

and replace ActiveDocument.Sections.Count in the above code with j

Next j

I hope this helps out

Regarding your other queries

About date :

Define data variable as string
i.e dim data as String
and the use data =3D Format(Date," desired format")
to get the system date in desired format

About quitting word

use Application.quit to quit Word


----- Original Message -----
From: dtudose@y...
Sent: 08 June, 2002 8:47 PM
To: VBA_Word
Subject: [vba_word] querying the shapes in section

thanks for the anchor parameter  Hemant

one more question

i did, with your help solve the problem of inserting shapes
in whichever section i want

but know i have to query the section with the last index
to find out which shape is type 9

it's simple for only one section:

For i =3D 1 To Application.ActiveDocument.Shapes.Count
    If Application.ActiveDocument.Shapes(i).Type =3D 9 Then
         auxiliar =3D Application.ActiveDocument.Shapes(i).Top
         If auxiliar > margineaDeJos Then
            lungimeSageata =3D Application.ActiveDocument.Shapes(i).Heigh
             margineaDeJos =3D auxiliar
         End If
    End If

but how about for the last section?

i tryed activedocument.sections.count for the index of the last
section..it's good
but i don't know how to fetch the individual shape in the last section
and furthermore how to fetch the top, heigth propreties of these shapes

thanks again


another 2 small problems:

how to extract the corect date of the system in our days , not the
medieval times
for example: i declared
dim data as Date
and it gave me the date 30 12 1899
i don't want that :))

and the second thing

how to make the word application object close complete
i tryed the quit method
i tryed the activewindow.close

nothing works
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.

  Return to Index