This Tutorial will demonstrate on looping through and reading bookmarks. #practicalit #wordvba #learnvba #easyvba #bookmarks #learnwordvba #vba #macro #Macros #whatisbookmarks #wordbookmarks
Hi Sir, I have one VBA document, In which I have below code, so I want to know what is the use of "variable" in the document, Please make one video on same topic, Thanks Private Function IsReady() As Boolean Dim x As Variable For Each x In ActiveDocument.Variables If x.Name = "DocunizeGenerated" Then If x.Value = "True" Then IsReady = True End If Next End Function
'Example-1 Sub LoopthroughBookmarks() Dim Bookm As bookmark For Each Bookm In ActiveDocument.Bookmarks Debug.Print "Bookmark Name : " & Bookm.Name Debug.Print "Bookmark Range/Text : " & Bookm.Range.Text Next Bookm End Sub 'Example-2 Sub Read_Bookmarks() Dim targetbkm As String targetbkm = "NewBK" 'bkm exists or not If ActiveDocument.Bookmarks.Exists(targetbkm) Then
Dim bkmrange As Range Set bkmrange = ActiveDocument.Bookmarks(targetbkm).Range
Debug.Print bkmrange.Text Else MsgBox "Sorry Bookmarks doesnt exist" End If End Sub
Very nice video sir
Hi Sir, please cover range property in more detail..
Will do soon
What is use of Variable property in word vba please make video on same as well..
You mean documents property
Hi Sir,
I have one VBA document, In which I have below code, so I want to know what is the use of "variable" in the document, Please make one video on same topic, Thanks
Private Function IsReady() As Boolean
Dim x As Variable
For Each x In ActiveDocument.Variables
If x.Name = "DocunizeGenerated" Then
If x.Value = "True" Then IsReady = True
End If
Next
End Function
How mailmerge will be create using bookmark vba
'Example-1
Sub LoopthroughBookmarks()
Dim Bookm As bookmark
For Each Bookm In ActiveDocument.Bookmarks
Debug.Print "Bookmark Name : " & Bookm.Name
Debug.Print "Bookmark Range/Text : " & Bookm.Range.Text
Next Bookm
End Sub
'Example-2
Sub Read_Bookmarks()
Dim targetbkm As String
targetbkm = "NewBK"
'bkm exists or not
If ActiveDocument.Bookmarks.Exists(targetbkm) Then
Dim bkmrange As Range
Set bkmrange = ActiveDocument.Bookmarks(targetbkm).Range
Debug.Print bkmrange.Text
Else
MsgBox "Sorry Bookmarks doesnt exist"
End If
End Sub