VBA Word - Exemplos de Códigos - B - Em ordem alfabética.


Termo de Responsabilidade

« B »
BackspaceSelection.TypeBackspace
Bookmark, Add:
With ActiveDocument.Bookmarks    .Add Range:=Selection.Range, Name:="Name"    .DefaultSorting = wdSortByName    .ShowHidden = False End With
Bookmark, Count # of Bookmarks in Document:
Dim intNumBookmarks as Integer intNumBookmarks = ActiveDocument.Bookmarks.Count
Bookmark, Delete:
ActiveDocument.Bookmarks("BookmarkName").Delete
Bookmark, Exists (Does It Exist?):
If ActiveDocument.Bookmarks.Exists("BookmarkName") = True then    'Do something, i.e.,:    ActiveDocument.Bookmarks("BookmarkName").Select    Selection.TypeText Text:="Hello" End If
Bookmark, Go to Bookmark: (This method does not work with bookmarks in Headers/Footers)
Selection.GoTo What:=wdGoToBookmark, Name:="Name"
Bookmark, Select a Bookmark: (This method works when using bookmarks in Headers/Footers)
ActiveDocument.Bookmarks("BookmarkName").Select
Bookmark, Insert Text Using Range (Change Content of Range): (This method works when using bookmarks in Headers/Footers)
ActiveDocument.Bookmarks("BookmarkName").Range.Text="Text"
Bookmark, Insert Text Using Range (Add After Range): (This method works when using bookmarks in Headers/Footers)
ActiveDocument.Bookmarks("BookmarkName").Range.InsertAfter _    "Text"
Bookmark, Go to a Bookmark, replace the text that's contained in the Bookmark, and still have the text bookmarked:
Selection.GoTo What:=wdGoToBookmark, Name:="BookmarkName" Selection.Delete Unit:=wdCharacter, Count:=1 Selection.InsertAfter "This is the new text" ActiveDocument.Bookmarks.Add Range:=Selection.Range, _    Name:="BookmarkName"
Bookmark, Replace Text of a Bookmark in document2 With the Text of a Bookmark in document1: Note that both documents must be open when the macro is run.
Documents("c:\temp\document2.doc").Bookmarks("doc2BookmarkName").Range.Text = _    Documents("c:\temp\document1.doc").Bookmarks("doc1BookmarkName").Range.Text Alternate Code: Documents("c:\temp\document2.doc").Bookmarks(1).Range.Text = _    Documents("c:\temp\document1.doc").Bookmarks(4).Range.Text where the text of the 4th bookmark in document1 is replacing the text of the 1st bookmark in document2. Bookmark, Turn Off View Bookmarks:
Bookmark, Turn Off View Bookmarks:Bookmark, Turn Off View Bookmarks:
ActiveWindow.View.ShowBookmarks = False

Reference:
Tags: Macro, Microsoft, MS, Office, VBA, Word, code, bookmark 

Inline image 1

Nenhum comentário:

Postar um comentário

diHITT - Notícias