Add Method

       

Add method as it applies to the Columns object.

Adds a new Column object to the specified Columns object and returns the new Column object.

expression.Add(BeforeColumn)

expression   Required. An expression that returns a Columns object.

BeforeColumn  Optional Long. The number of the column before which to insert the new column. If this argument is omitted, the new column is added after the existing columns. An error occurs if the value of this argument does not correspond to an existing column in the table.

Add method as it applies to the Hyperlinks object.

Adds a new Hyperlink object to the specified Hyperlinks object and returns the new Hyperlink object.

expression.Add(Text, Address, RelativePage, PageID, TextToDisplay)

expression   Required. An expression that returns a Hyperlinks object.

Text  Required TextRange object. The text range to be converted into hyperlink.

Address  Optional String. The address of the new hyperlink. If RelativePage is pbHlinkTargetTypeURL (default) or pbHlinkTargetTypeEmail, then Address must be specified or an error occurs.

RelativePage  Optional PbHlinkTargetType. The type of hyperlink to add.

PbHlinkTargetType can be one of these PbHlinkTargetType constants.
pbHlinkTargetTypeEmail
pbHlinkTargetTypeFirstPage
pbHlinkTargetTypeLastPage
pbHlinkTargetTypeNextPage
pbHlinkTargetTypeNone Not supported.
pbHlinkTargetTypePageID
pbHlinkTargetTypePreviousPage
pbHlinkTargetTypeURL default

PageID  Optional Long. The page ID of the destination page for the new hyperlink. If RelativePage is pbHlinkTargetTypePageID, then PageID must be specified or an error occurs. The page ID corresponds to the PageID property of the destination page.

TextToDisplay  Optional String. The display text of the new hyperlink. If specified, TextToDisplay replaces the text range specified by the Text argument.

Add method as it applies to the MailMergeFilters object.

Adds a new filter criterion to the specified MailMergeFilters object.

expression.Add(Column, Comparison, Conjunction, bstrCompareTo, DeferUpdate)

expression   Required. An expression that returns a MailMergeFilters object.

Column  Required String. The name of the table in the data source.

Comparison  Required MsoFilterComparison. How the data in the table is filtered.

MsoFilterComparison can be one of these MsoFilterComparison constants.
msoFilterComparisonContains
msoFilterComparisonEqual
msoFilterComparisonGreaterThan
msoFilterComparisonGreaterThanEqual
msoFilterComparisonIsBlank
msoFilterComparisonIsNotBlank
msoFilterComparisonLessThan
msoFilterComparisonLessThanEqual
msoFilterComparisonNotContains
msoFilterComparisonNotEqual

Conjunction  Required MsoFilterConjunction. Determines how this filter relates to other filters in the MailMergeFilters object.

MsoFilterConjunction can be one of these MsoFilterConjunction constants.
msoFilterConjunctionAnd
msoFilterConjunctionOr

bstrCompareTo  Optional String. If the Comparison argument is something other than msoFilterComparisonIsBlank or msoFilterComparisonIsNotBlank, a string to which the data in the table is compared.

DeferUpdate  Optional Boolean. True to queue up the filters and apply them when the ApplyFilter method is called. False to apply the filter condition immediately. Default is False.

Add method as it applies to the Pages object.

Adds a new Page object to the specified Pages object and returns the new Page object.

expression.Add(Count, After, DuplicateObjectsOnPage)

expression   Required. An expression that returns a Pages object.

Count  Required Long. The number of new pages to add.

After  Required Long. The page index of the page after which to add the new pages. A zero for this argument adds new pages at the beginning of the publication.

DuplicateObjectsOnPage  Optional Long. The page index of the page from which objects should be copied to the new pages. If this argument is omitted, the new pages will be blank.

Add method as it applies to the Plates object.

Adds a new color plate to the specified Plates object.

expression.Add(PlateColor)

expression   Required. An expression that returns a Plates object.

PlateColor  Optional ColorFormat object. The color settings to apply to the new plate.

Remarks

If the ColorMode property of the specified publication is not pbColorModeSpot or pbColorModeSpotAndProcess, an error occurs.

Add method as it applies to the Rows object.

Adds a new Row object to the specified Rows object and returns the new Row object.

expression.Add(BeforeRow)

expression   Required. An expression that returns a Rows object.

BeforeRow  Optional Long. The number of the row before which to insert the new row. If this argument is omitted, the new row is added after the existing rows. An error occurs if the value of this argument does not correspond to an existing row in the table.

Add method as it applies to the RulerGuides object.

Adds a new ruler guide to the specified RulerGuides object.

expression.Add(Position, Type)

expression   Required. An expression that returns a RulerGuides object.

Position  Required Variant. The position relative to the left or top edge of the page where the new ruler guide will be added. Numeric values are evaluated in points; strings are evaluated in the units specified and can be in any measurement unit supported by Microsoft Publisher (for example, "2.5 in").

Type  Required PbRulerGuideType. The type of ruler guide to add.

PbRulerGuideType can be one of these PbRulerGuideType constants.
pbRulerGuideTypeHorizontal
pbRulerGuideTypeVertical

Add method as it applies to the TabStops object.

Adds a new tab stop to the specified TabStops object.

expression.Add(Position, Alignment, Leader)

expression   Required. An expression that returns a TabStops object.

Position  Required Variant. The horizontal position of the new tab stop relative to the left edge of the text frame. Numeric values are evaluated in points; strings are evaluated in the units specified and can be in any measurement unit supported by Microsoft Publisher (for example, "2.5 in").

Alignment  Required PbTabAlignmentType. The alignment setting for the tab stop.

PbTabAlignmentType can be one of these PbTabAlignmentType constants.
pbTabAlignmentCenter
pbTabAlignmentDecimal
pbTabAlignmentLeading
pbTabAlignmentTrailing

Leader  Required PbTabLeaderType. The type of leader for the tab stop.

PbTabLeaderType can be one of these PbTabLeaderType constants.
pbTabLeaderBullet
pbTabLeaderDashes
pbTabLeaderDot
pbTabLeaderLine
pbTabLeaderNone

Add method as it applies to the Tags object.

Adds a new Tag object to the specified Tags object and returns the new Tag object.

expression.Add(Name, Value)

expression   Required. An expression that returns a Tags object.

Name  Required String. The name of the tag to add. If a tag already exists with the same name, an error occurs.

Value  Required Variant. The value to assign to the tag.

Add method as it applies to the TextStyles object.

Adds a new TextStyle object to the specified TextStyles object and returns the new TextStyle object.

expression.Add(Font, ParagraphFormat, StyleName, BasedOn)

expression   Required. An expression that returns a TextStyles object.

StyleName  Required String. The name of the new text style. If the name matches an existing text style, the existing text style is overwritten.

BasedOn  Optional String. The name of the text style on which the new text style is based. If the name doesn't match an existing text style, an error occurs.

Font  Optional Font object. The font settings to apply to the new text style.

ParagraphFormat  Optional ParagraphFormat object. The paragraph formatting to apply to the new text style.

Add method as it applies to the WebHiddenFields object.

Adds a new hidden field to a Web form and returns a Long indicating the number of the new field in the WebHiddenFields collection. New  fields are always placed at the end of the current field list.

expression.Add(Name, Value)

expression   Required. An expression that returns a WebHiddenFields object.

Name  Required String. The name of the new field.

Value  Required String. The value of the new field.

Example

As it applies to the Columns object.

The following example adds a column before column three in the specified table.

Dim colNew As Column

Set colNew = ActiveDocument.Pages(1).Shapes(1) _
    .Table.Columns.Add(BeforeColumn:=3)

As it applies to the Hyperlinks object.

The following example adds hyperlinks to shapes one and two on page one of the active publication. The first hyperlink points to http://www.microsoft.com, and the second link points to the fourth page in the publication. Shapes one and two must be text boxes and there must be at least four pages in the publication for this example to work.

Dim hypNew As Hyperlink
Dim lngPageID As Long
Dim strPage As String

With ActiveDocument.Pages(1).Shapes(1).TextFrame
    Set hypNew = .TextRange.Hyperlinks.Add(Text:=.TextRange, _
        Address:="http://www.microsoft.com", _
        TextToDisplay:="Microsoft")
End With

lngPageID = ActiveDocument.Pages(4).PageID
strPage = "Go to page " _
    & Str(ActiveDocument.Pages(4).PageNumber)

With ActiveDocument.Pages(1).Shapes(2).TextFrame
    Set hypNew = .TextRange.Hyperlinks.Add(Text:=.TextRange, _
        RelativePage:=pbHlinkTargetTypePageID, _
        PageID:=lngPageID, _
        TextToDisplay:=strPage)
End With

As it applies to the Pages object.

The following example adds four new pages after the first page in the publication, and copies all the objects from the first page to the new pages.

Dim pgNew As Page

Set pgNew = ActiveDocument.Pages _
    .Add(Count:=4, After:=1, DuplicateObjectsOnPage:=1)

As it applies to the Plates object.

The following example adds a color plate to the active publication if it is a spot-color publication.

If ActiveDocument.ColorMode = pbColorModeSpot Then
    ActiveDocument.Plates.Add
End If

As it applies to the Rows object.

The following example adds a row before row three in the specified table.

Dim rowNew As Row

Set rowNew = ActiveDocument.Pages(1).Shapes(1) _
    .Table.Rows.Add(BeforeRow:=3)

As it applies to the RulerGuides object.

The following example adds ruler guides to page one that are 0.5 inches from the left and top edges of the page.

With ActiveDocument.Pages(1).RulerGuides
    .Add Position:="0.5 in", Type:=pbRulerGuideTypeHorizontal
    .Add Position:="0.5 in", Type:=pbRulerGuideTypeVertical
End With

As it applies to the TabStops object.

The following example adds a new left-aligned tab stop 0.5 inches from the left edge of the specified text frame.

ActiveDocument.Pages(1).Shapes(1).TextFrame _
    .TextRange.ParagraphFormat.Tabs _
    .Add Position:="0.5 in", _
    Alignment:=pbTabAlignmentLeading, _
    Leader:=pbTabLeaderNone

As it applies to the Tags object.

The following example adds a tag to shape one on page one of the active publication.

Dim tagNew As Tag

Set tagNew = ActiveDocument.Pages(1).Shapes(1).Tags _
    .Add(Name:="required", Value:="yes")

As it applies to the TextStyles object.

The following example adds a new text style to the active publication based on the Normal text style.

Dim tsNew As TextStyle

Set tsNew = ActiveDocument.TextStyles _
    .Add(StyleName:="Title", BasedOn:="Normal")

As it applies to the WebHiddenFields object.

The following example adds a new hidden field to the specified Web command button control. Shape one on page one of the active publication must be a Web command button control for this example to work.

ActiveDocument.Pages(1).Shapes(1) _
    .WebCommandButton.HiddenFields _
    .Add Name:="subject", Value:="service request"