FRAMES positioning

D

DarcoB

Hi everyone,
I NEED HELP WITH FRAMES!
Working on a 200 pages document with 5-10 frames on each page(marginalia
beside text). Someone was "smart" enough to manually move every frame out of
its regular position. Now it would take me forever to position every frame
back to its original position. So I tried to write a macro to do the job.
Beginner as I am, it looked like this:

Sub frame_position()
Dim frm As Frame
For Each frm In ActiveDocument.Frames
frm.Select
frm.HorizontalPosition = wdFrameOutside
frm.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
frm.HorizontalDistanceFromText = CentimetersToPoints(0.7)

Next frm
End Sub

It worked somehow. But. It comes to a first table, where it stops, and says:
This command is not available!

Any solutions?
Thanks to all good people.
 
S

Stefan Blom

It seems as if tables with text wrapping are also considered a type of
frames in Word. You should be able to use the following code to make sure
that the found Frame object is not a table:

Sub main()
Dim f As Frame
For Each f In ActiveDocument.Frames
If Not f.Range.Information(wdWithInTable) Then
f.HorizontalPosition = wdFrameOutside
f.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
f.HorizontalDistanceFromText = CentimetersToPoints(0.7)
'Debug.Print f.Range.Text 'just testing...
End If
Next f
End Sub
 
D

DarcoB

Thank You,
I will try that ASAP.
LG
Darko

Stefan Blom said:
It seems as if tables with text wrapping are also considered a type of
frames in Word. You should be able to use the following code to make sure
that the found Frame object is not a table:

Sub main()
Dim f As Frame
For Each f In ActiveDocument.Frames
If Not f.Range.Information(wdWithInTable) Then
f.HorizontalPosition = wdFrameOutside
f.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
f.HorizontalDistanceFromText = CentimetersToPoints(0.7)
'Debug.Print f.Range.Text 'just testing...
End If
Next f
End Sub
 

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