Class Frame (Word VBA)

The class Frame represents a frame. The Frame object is a member of the Frames collection. The Frames collection includes all frames in a selection, range, or document.

The main procedures of class Frame are Copy, Delete, Select, Frames.Add and Frames.Delete

Set

To use a Frame class variable it first needs to be instantiated, for example

Dim frm as Frame
Set frm = ActiveDocument.Frames(Index:=1)

The following procedures can be used to set variables of type Frame: Find.Frame, Frames.Add, Frames.Item, Replacement.Frame, Style.Frame, Document.Frames, Range.Frames and Selection.Frames

For Each

Here is an example of processing the Frame items in a collection.

Dim frm As Frame
For Each frm In ActiveDocument.Frames
	
Next frm

Methods

These are the main methods of the Frame class

Copy - Copies the specified frame to the Clipboard.

ActiveDocument.Frames(1).Copy

Delete - Deletes the specified frame.

ActiveDocument.Frames(1).Delete

Select - Selects the specified object.

ActiveDocument.Frames(1).Select

Frames.Add - Returns a Frame object that represents a new frame added to a range, selection, or document.

Dim frm As Frame
Set frm = ActiveDocument.Frames.Add(Range:=)

Frames.Delete - Deletes the specified Frames collection.

ActiveDocument.Frames.Delete

Properties

Borders returns a Borders collection that represents all the borders for the specified frame.

ActiveDocument.Frames(1).Borders =

Height returns or sets a Single that represents the height (in points) of the specified frame.

ActiveDocument.Frames(1).Height =

HeightRule returns or sets a WdFrameSizeRule that represents the rule for determining the height of the specified frame.

ActiveDocument.Frames(1).HeightRule = wdFrameAtLeast

HorizontalDistanceFromText returns or sets the horizontal distance between a frame and the surrounding text, in points.

ActiveDocument.Frames(1).HorizontalDistanceFromText =

HorizontalPosition returns or sets the horizontal distance between the edge of the frame and the item specified by the RelativeHorizontalPosition property.

ActiveDocument.Frames(1).HorizontalPosition =

LockAnchor true if the specified frame is locked.

ActiveDocument.Frames(1).LockAnchor = True

Parent returns an object that represents the parent object of the specified Frame object.

Dim objParent As Object
Set objParent = ActiveDocument.Frames(1).Parent

Range returns a Range object that represents the portion of a document that's contained within the frame.

Dim rngRange As Range
Set rngRange = ActiveDocument.Frames(1).Range

RelativeHorizontalPosition specifies the relative horizontal position of a frame.

ActiveDocument.Frames(1).RelativeHorizontalPosition = wdRelativeHorizontalPositionCharacter

RelativeVerticalPosition specifies the relative vertical position of a frame.

ActiveDocument.Frames(1).RelativeVerticalPosition = wdRelativeVerticalPositionBottomMarginArea

Shading returns a Shading object that refers to the shading formatting for the specified object.

Dim shdShading As Shading
Set shdShading = ActiveDocument.Frames(1).Shading

TextWrap true if document text wraps around the specified frame.

ActiveDocument.Frames(1).TextWrap = True

VerticalDistanceFromText returns or sets the vertical distance (in points) between a frame and the surrounding text.

ActiveDocument.Frames(1).VerticalDistanceFromText =

VerticalPosition returns or sets the vertical distance between the edge of the frame and the item specified by the RelativeVerticalPosition property.

ActiveDocument.Frames(1).VerticalPosition =

Width returns or sets the width (in points) of the frame, in points.

ActiveDocument.Frames(1).Width =

WidthRule returns or sets the rule used to determine the width of a frame.

ActiveDocument.Frames(1).WidthRule = wdFrameAtLeast

Frames.Count returns a Long that represents the number of frames in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Frames.Count

Frames.Parent returns an object that represents the parent object of the specified Frames object.

Dim objParent As Object
Set objParent = ActiveDocument.Frames.Parent