M
mahern
I have a Word 2007 document converted from an HTML file. Word has converted
certain tags to bookmarks. For arguments sake, say "mikebegin" repeats
multiple times throughout the document, represents a specific section in the
document, and needs to be manipulated (e.g., changing the font to bold,
italics). I have been trying to write a macro that selects each instance of
the bookmark and makes the appropriate change. However, if I select the
bookmark using the following code, it selects all non-related text between
the bookmarks (i.e., between the "mikeend" and next "mikebegin" bookmarks:
Sub Junk()
'
' Junk Macro
'
Set Book1 = ActiveDocument.Bookmarks("mikebegin")
Set Book2 = ActiveDocument.Bookmarks("mikeend")
'If Book2.End > Book1.Start Then Book1.Select
Selection.GoTo What:=wdGoToBookmark, Name:="mikebegin"
Selection.Bookmarks(1).Range.Bold = True
End Sub
I have noticed that if the document has only one "mikebegin" bookmark; the
Selection.Bookmarks(1).Range.Bold = True selects the text only down to a
</td> code that was generated as part of the original html file rather than
to the end of the document. But if more than one instance of the named
bookmark is present in the document, all text betwen the beginning of the
first instance of the bookmark and the </td> code for the second instance of
the bookmark is selected and manipulated by the macro code above.
So, in summary, I am trying to, in essence, multiple select text associated
with a recurring bookmark, and manipulate that text only; not the unrelated
text between the bookmarked text.
Thanks in advance for your help!
certain tags to bookmarks. For arguments sake, say "mikebegin" repeats
multiple times throughout the document, represents a specific section in the
document, and needs to be manipulated (e.g., changing the font to bold,
italics). I have been trying to write a macro that selects each instance of
the bookmark and makes the appropriate change. However, if I select the
bookmark using the following code, it selects all non-related text between
the bookmarks (i.e., between the "mikeend" and next "mikebegin" bookmarks:
Sub Junk()
'
' Junk Macro
'
Set Book1 = ActiveDocument.Bookmarks("mikebegin")
Set Book2 = ActiveDocument.Bookmarks("mikeend")
'If Book2.End > Book1.Start Then Book1.Select
Selection.GoTo What:=wdGoToBookmark, Name:="mikebegin"
Selection.Bookmarks(1).Range.Bold = True
End Sub
I have noticed that if the document has only one "mikebegin" bookmark; the
Selection.Bookmarks(1).Range.Bold = True selects the text only down to a
</td> code that was generated as part of the original html file rather than
to the end of the document. But if more than one instance of the named
bookmark is present in the document, all text betwen the beginning of the
first instance of the bookmark and the </td> code for the second instance of
the bookmark is selected and manipulated by the macro code above.
So, in summary, I am trying to, in essence, multiple select text associated
with a recurring bookmark, and manipulate that text only; not the unrelated
text between the bookmarked text.
Thanks in advance for your help!