B
Bill Foley
Hey Gang,
Back again with another question that has me pulling out the remaining two
hairs.
I have a bunch of bookmarks that I am searching for in a document and
selecting all bookmarks that do not meet that criteria to make subdocuments.
All has been working fine, but now I need to do a search for either of two
bookmark names and delete the others.
I have been trying a couple of variations of OR, but to no avail. The
original code for a given bookmark is as follows:
For Each MyBook In ActiveDocument.Bookmarks
If InStr(1, MyBook.Name, "por_") = 0 Then
MyBook.Range.Delete
End If
Next
This looks for sequenced bookmarks that start with "por_" and deletes
anything but. I want it to look for both "por_" AND "poi_" and delete
anything else. I have tried the following to no avail:
1.
For Each MyBook In ActiveDocument.Bookmarks
If InStr(1, MyBook.Name, "por_""poi_") = 0 Then
MyBook.Range.Delete
End If
Next
2.
For Each MyBook In ActiveDocument.Bookmarks
If InStr(1, MyBook.Name, "por_") = 0 OR InStr(1, MyBook.Name,
"por_") = 0 Then
MyBook.Range.Delete
End If
Next
I have tried a few others that are too embarrassing to post.
Anyone know the correct syntax? TIA!
Back again with another question that has me pulling out the remaining two
hairs.
I have a bunch of bookmarks that I am searching for in a document and
selecting all bookmarks that do not meet that criteria to make subdocuments.
All has been working fine, but now I need to do a search for either of two
bookmark names and delete the others.
I have been trying a couple of variations of OR, but to no avail. The
original code for a given bookmark is as follows:
For Each MyBook In ActiveDocument.Bookmarks
If InStr(1, MyBook.Name, "por_") = 0 Then
MyBook.Range.Delete
End If
Next
This looks for sequenced bookmarks that start with "por_" and deletes
anything but. I want it to look for both "por_" AND "poi_" and delete
anything else. I have tried the following to no avail:
1.
For Each MyBook In ActiveDocument.Bookmarks
If InStr(1, MyBook.Name, "por_""poi_") = 0 Then
MyBook.Range.Delete
End If
Next
2.
For Each MyBook In ActiveDocument.Bookmarks
If InStr(1, MyBook.Name, "por_") = 0 OR InStr(1, MyBook.Name,
"por_") = 0 Then
MyBook.Range.Delete
End If
Next
I have tried a few others that are too embarrassing to post.
Anyone know the correct syntax? TIA!