Insert Method

Microsoft Publisher Visual Basic

Show All Show All

Insert Method

ShowAs it applies to the MailMergeDataField object .

Adds a Shape object that represents a picture data field inserted into the publication's catalog merge area.

expression.Insert(Range)

expression    Required. An expression that returns a MailMergeDataField object.

Range   Optional TextRange.

Remarks

Returns "Permission Denied" for text data fields. Before a data field is inserted into a publication's catalog merge area using the Insert method, the field must be defined as a picture data field. Use the FieldType property of the MailMergeDataField object to specify a data field's type.

Use the InsertMailMergeField method of the TextRange object to add a text data field to a text box in the publication's catalog merge area.

This method corresponds to inserting picture fields into the catalog merge area in Step 3: Create your catalog merge template of the Mail and Catalog Merge Wizard.

ShowAs it applies to the ShapeNodes collection.

Inserts a new segment after the specified node of the freeform drawing.

expression.Insert(Index, SegmentType, EditingType, X1, Y1, X2, Y2, X3, Y3)

expression    Required. An expression that returns one of the above objects.

Index   Required Long. The number of the node after which the new node is to be inserted.

SegmentType   Required MsoSegmentType. The type of segment to be added.

MsoSegmentType can be one of these MsoSegmentType constants.
msoSegmentCurve
msoSegmentLine

EditingType   Required MsoEditingType. Specifies the editing type of the new node.

MsoEditingType can be one of these MsoEditingType constants.
msoEditingAuto Adds a node type appropriate to the segments being connected.
msoEditingCorner Adds a corner node.
msoEditingSmooth Not used with this method.
msoEditingSymmetric Not used with this method.

X1   Required Variant. If the EditingType of the new segment is msoEditingAuto, this argument specifies the horizontal distance from the upper-left corner of the page to the end point of the new segment. If the EditingType of the new node is msoEditingCorner, this argument specifies the horizontal distance from the upper-left corner of the page to the first control point for the new segment.

Y1   Required Variant. If the EditingType of the new segment is msoEditingAuto, this argument specifies the vertical distance from the upper-left corner of the page to the end point of the new segment. If the EditingType of the new node is msoEditingCorner, this argument specifies the vertical distance from the upper-left corner of the page to the first control point for the new segment.

X2   Optional Variant. If the EditingType of the new segment is msoEditingCorner, this argument specifies the horizontal distance from the upper-left corner of the page to the second control point for the new segment. If the EditingType of the new segment is msoEditingAuto, do not specify a value for this argument.

Y2   Optional Variant. If the EditingType of the new segment is msoEditingCorner, this argument specifies the vertical distance from the upper-left corner of the page to the second control point for the new segment. If the EditingType of the new segment is msoEditingAuto, do not specify a value for this argument.

X3   Optional Variant. If the EditingType of the new segment is msoEditingCorner, this argument specifies the horizontal distance from the upper-left corner of the page to the end point of the new segment. If the EditingType of the new segment is msoEditingAuto, do not specify a value for this argument.

Y3   Optional Variant. If the EditingType of the new segment is msoEditingCorner, this argument specifies the vertical distance from the upper-left corner of the page to the end point of the new segment. If the EditingType of the new segment is msoEditingAuto, do not specify a value for this argument.

Remarks

For the X1, Y1, X2, Y2, X3, and Y3 arguments, numeric values are evaluated in points; strings can be in any units supported by Publisher (for example, "2.5 in").

Example

ShowAs it applies to the MailMergeDataField object.

This example defines a data field as a picture data field, inserts it into the catalog merge area of the specified publication, and sizes and positions the picture data field. This example assumes the publication has been connected to a data source, and a catalog merge area has been added to the publication.

Dim pbPictureField1 As Shape

    'Define the field as a picture data type
    With ThisDocument.MailMerge.DataSource.DataFields
        .Item("Photo:").FieldType = pbMailMergeDataFieldPicture
    End With
    
    'Insert a picture field, then size and position it
    Set pbPictureField1 = ThisDocument.MailMerge.DataSource.DataFields.Item("Photo:").Insert
        With pbPictureField1
            .Height = 100
            .Width = 100
            .Top = 85
            .Left = 375
        End With
		

ShowAs it applies to the ShapeNodes collection.

This example adds a smooth node with a curved segment after node four in the third shape in the active publication. The shape must be a freeform drawing with at least four nodes.

With ActiveDocument.Pages(1).Shapes(3).Nodes
    .Insert Index:=4, _
        SegmentType:=msoSegmentCurve, _
        EditingType:=msoEditingAuto, _
        X1:=210, Y1:=100
End With