Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
mememe12 Profile
Femeie
23 ani
Bucuresti
cauta Barbat
23 - 80 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [WORD] Bookmarks Insert, Show-Hide and Batch Delete [VBA] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
Normally you can remove 1 bookmark at a time (INSERT - Bookmark, select it then press Delete). You cannot select multiple Bookmarks and delete them, only via VBA.

Remove all bookmarks - simple method


Sub BookmarksRemoveAll()
Dim bkm As Bookmark
    For Each bkm In ActiveDocument.Bookmarks
        bkm.Delete
    Next bkm
End Sub


Source:

Batch Delete All Bookmarks in a Document - more complex, asks you "Do you want to remove all X bookmarks in this document?" and confirms the deletion showing a confirmation box,


Sub DeleteAllBookmarksInDoc()
  Dim objBookmark As Bookmark
  Dim nBookmark As Integer
  Dim strButtonValue As String
  Dim objDoc As Document

  Application.ScreenUpdating = False

  Set objDoc = ActiveDocument
  nBookmark = objDoc.Bookmarks.Count
  If nBookmark > 0 Then
    strButtonValue = MsgBox("Do you want to remove all " & nBookmark & " bookmark(s) in this document?", vbYesNo)
    If strButtonValue = vbYes Then
      For Each objBookmark In objDoc.Bookmarks
        objBookmark.Delete
      Next objBookmark
      MsgBox ("All bookmarks in this document have been deleted.")
    Else
      Exit Sub
    End If
  End If

  Application.ScreenUpdating = True
End Sub


Source:

Batch Delete All Bookmarks in a Selection, asks you "Do you want to remove all X bookmarks in this document?" and confirms the deletion showing a confirmation box,


Sub DeleteAllBookmarksInSelection()
  Dim objBookmark As Bookmark
  Dim nBookmark As Integer
  Dim strButtonValue As String

  Application.ScreenUpdating = False

  nBookmark = Selection.Bookmarks.Count
  If nBookmark > 0 Then
    strButtonValue = MsgBox("Do you want to remove all " & nBookmark & " bookmark(s) in this selection?", vbYesNo)
    If strButtonValue = vbYes Then
      For Each objBookmark In Selection.Bookmarks
        objBookmark.Delete
      Next objBookmark
      MsgBox ("All " & nBookmark & " bookmark(s) in this selection have been deleted.")
    Else
      Exit Sub
    End If
  End If

  Application.ScreenUpdating = True
End Sub


Source:


pus acum 4 ani
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
Insert a bookmark. Run code, type bookmark name and hit OK.


Sub BookmarkInsert_PgNum()

Dim PgNum As String
PgNum = InputBox("Type desired name for bookmark")

With ActiveDocument
    Selection.Bookmarks.Add Range:=Selection.Range, Name:=PgNum
End With
   
End Sub


pus acum 4 ani
   
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
Show / hide bookmarks in the active document - show hide the sign letting you know that there is a bookmark

This is normally done via FILE - Options - Advanced - Show document content and adding/removing a check to Show bookmarks.


Sub BookmarksShowHide()

If ActiveWindow.View.ShowBookmarks = False Then
    ActiveWindow.View.ShowBookmarks = True
    Else: ActiveWindow.View.ShowBookmarks = False
End If

End Sub


Modificat de TRaP (acum 4 ani)


pus acum 4 ani
   
Pagini: 1  

Mergi la