S
Senapathy
Hello,
I am using VBA for Word to validate whether a report Word Doc is fine.
For this, I scan through the doc for certain bookmarks.
If the bookmarks are not present at all, it is a major problem and I signal
error and return.
If the bookmarks are present, I would like to read the text soon after the
bookmark and check if it is not empty. That is all.
But I am not able to do this.
Can anyone point me how to do this?
Currently the code that I use to scan for the bookmarks is thus:
If ActiveDocument.Bookmarks.Exists("bkMark") = False Then
bInvalidReport = True
strInvalidFields = strInvalidFields + Chr(10) + p_strField + " "
Else
' TODO : Check for valid entries for the bookmarks
End If
For the Checking for valid entries, I have tried the following things, which
do not work:
Selection.GoTo What:=wdGoToBookmark, Name:="bkMark"
If IsEmpty(Selection.Text) then
....
This doesn't work because even if there is nothing after the bookmark but
blank characters, the bookmark always contains some vague ASCII character.
If I try
ActiveDocument.Bookmarks.("bkMark").Empty = True
.....
then it always returns empty for me, indicating a problem with every
field.
Warm regards,
Senapathy
I am using VBA for Word to validate whether a report Word Doc is fine.
For this, I scan through the doc for certain bookmarks.
If the bookmarks are not present at all, it is a major problem and I signal
error and return.
If the bookmarks are present, I would like to read the text soon after the
bookmark and check if it is not empty. That is all.
But I am not able to do this.
Can anyone point me how to do this?
Currently the code that I use to scan for the bookmarks is thus:
If ActiveDocument.Bookmarks.Exists("bkMark") = False Then
bInvalidReport = True
strInvalidFields = strInvalidFields + Chr(10) + p_strField + " "
Else
' TODO : Check for valid entries for the bookmarks
End If
For the Checking for valid entries, I have tried the following things, which
do not work:
Selection.GoTo What:=wdGoToBookmark, Name:="bkMark"
If IsEmpty(Selection.Text) then
....
This doesn't work because even if there is nothing after the bookmark but
blank characters, the bookmark always contains some vague ASCII character.
If I try
ActiveDocument.Bookmarks.("bkMark").Empty = True
.....
then it always returns empty for me, indicating a problem with every
field.
Warm regards,
Senapathy