Frames
Word does not provide a frame-management facility. Frames were orphaned with the release of Word97.
Legacy documents and legacy habits continue to provoke problems with frames.
These procedures attempt to reduce the frustration associated with frames.
As a minimum, we wish that Word’s Edit-Replace dialogue provided an option to replace frames in the sense that we can replace section breaks and other non-text items.
We will provide ability to locate and select the next frame, to clear all frames, to count the frames in a document.
Replacement of a frame prompts us to ask what makes sense as a replacement?
The procedures supplied allow the developer to:
- Count frames within a range
- Select the first frame in a range (GoTo)
- Select the last frame in a range (GoTo)
- Move forward one frame
- Move backward one frame
- Delete all frames within a range (except those frames that lie within tables).
These procedures could form the basis of a GUI form similar to Word's Edit, Replace.
Public Function lngCountFrames(rng As Range) As Long
Public Function SelectBackwardFrame(ByVal rng As Range)
Public Function SelectFirstFrame(rng As Range)
Public Function SelectForwardFrame(ByVal rng As Range)
Public Function SelectLastFrame(rng As Range)
Here is a crude attempt to circumvent the frame/table problem:
Dim lng As Long
For lng = rng.Frames.Count To 1 Step -1
If rng.Frames(lng).Range.Information(wdWithInTable) Then
' MsgBox "I cannot delete frames within tables"
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:=True
rng.Frames(lng).Delete
Selection.ConvertToTable Separator:=wdSeparateByTabs, Format:=wdTableFormatNone
Else
rng.Frames(lng).Delete
End If
Next lng
End Function
Sub TESTDeleteFrames()
Call DeleteFrames(Selection.Range)
End Sub