Share via


Add Method [Publisher 2003 VBA Language Reference]

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.

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 a hyperlink.

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

PbHlinkTargetType

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

PageID  Optional Long. The page ID of the destination page for the new hyperlink. If RelativePage is pbHlinkTargetTypePageID, 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.

MsoFilterComparison

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

MsoFilterConjunction

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 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 MasterPages object.

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

expression.Add([IsTwoPageMaster], [Abbreviation], [Description],)

expression Required. An expression that returns a MasterPages object.

IsTwoPageMaster  Optional Boolean. True if the master page will be part of a two page spread.

Abbreviation  Optional String. The abbreviation, or short name, for the master page. An error occurs if this is not unique.

Description  Optional String. The description for the master page.

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], [AddHyperlinkToWebNavBar])

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.

AddHyperlinkToWebNavBar  Optional Boolean. Specifies whether links to the new pages will be added to the automatic navigation bars of existing pages. If True, links to the new pages will be added to the automatic navigation bars of existing pages only. If False, links to the new pages will not be added to the automatic navigation bars of existing pages or new pages added in the future. Default is False.

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 edge 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").

PbRulerGuideType

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").

PbTabAlignmentType

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

PbTabLeaderType

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 does not 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)

The following example adds hyperlinks to shapes one and two on page one of the active publication. The first hyperlink points to an external website, 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.tailspintoys.com/", _
        TextToDisplay:="Tailspin")
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 MasterPages object.

The following example adds a new master page to the active document.

ActiveDocument.MasterPages.Add _
    IsTwoPageMaster:=False, _
    Abbreviation:="X", _
    Description:="Master Page X"

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)

The following example demonstrates adding two new pages to the publication and setting the AddHyperlinkToWebNavBar parameter to True for these two pages. This specifies that links to these two new pages be added to the automatic navigation bars of existing pages and those added in the future.

Another page is then added to the publication, and the AddHyperlinkToWebNavBar is omitted. This means that the IncludePageOnNewWebNavigationBars property is False for the newly added page, and links to this page will not be included in the automatic navigation bars of existing pages.

Dim thePage As page
Dim thePage2 As page

Set thePage = ActiveDocument.Pages.Add(Count:=2, _
    After:=4, AddHyperlinkToWebNavBar:=True)

Set thePage2 = ActiveDocument.Pages.Add(Count:=1, After:=6)

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"

Applies to | Columns Collection | Documents Collection | Hyperlinks Collection | MailMergeFilters Collection | MasterPages Collection | Pages Collection | Plates Collection | Rows Collection | RulerGuides Collection | Sections Collection | TabStops Collection | Tags Collection | TextStyles Collection | WebHiddenFields Collection | WebNavigationBarHyperlinks Object