Update Method

Microsoft Word Visual Basic

Show All

Update Method

       

Update method as it applies to the Field object.

Updates the result of the field object. When applied to a Field object, returns True if the field is updated successfully.

expression.Update

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

Update method as it applies to the Fields object.

Updates the result of the fields object. When applied to a Fields collection, returns 0 (zero) if no errors occur when the fields are updated, or returns a Long that represents the index of the first field that contains an error.

expression.Update

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

Update method as it applies to the Dialog, Index, LinkFormat, TableOfAuthorities, TableOfContents, and TableOfFigures objects.

Updates the values shown in a built-in Microsoft Word dialog box, updates the specified link, or updates the entries shown in specified index, table of authorities, table of figures or table of contents.

Note   Use the UpdatePageNumbers method to update the page numbers of items in a table of contents or figures.

expression.Update

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

Example

As it applies to the Fields object.

This example updates all the fields in the active document. A return value of 0 (zero) indicates that the fields were updated without error.

If ActiveDocument.Fields.Update = 0 Then
    MsgBox "Update Successful"
Else
    MsgBox "Field " & ActiveDocument.Fields.Update & _
        " has an error"
End If

This example updates any fields in the active document that aren't updated automatically.

For Each afield In ActiveDocument.Fields
    If afield.LinkFormat.AutoUpdate = False _
        Then afield.LinkFormat.Update
Next afield

As it applies to the TableOfFigures object.

This example updates the first table of figures in the active document.

If ActiveDocument.TablesOfFigures.Count >= 1 Then
    ActiveDocument.TableOfFigures(1).Update
End If

As it applies to the Field object.

This example updates the first field in the active document and displays a message in the status bar indicating whether or not the field was updated successfully.

If ActiveDocument.Fields(1).Update = True Then
    StatusBar = "Field updated"
Else
    StatusBar = "Error, field not updated"
End If

As it applies to the Dialog object.

This example returns a Dialog object that refers to the Font dialog box. The font applied to the Selection object is changed to Arial, the dialog values are updated, and the Font dialog box is displayed.

Set myDialog = Dialogs(wdDialogFormatFont)
Selection.Font.Name = "Arial"
myDialog.Update
myDialog.Show