L
larryfergy
I have of file of searchfields I used to make bookmarks in a document. That
worked fine. But my intent was to build adobe acrobat pdf with bookmarks and
that just doesn't work.
So now I'm trying to update my searchs with styles that acrobat can regonize
on particular headings I have in my searchfield fiile I bring in.
I decided to use heading1 and heading2 styles in the document. I modified
them to have different format. Thats ok I have on 2 levels (one parent /
child)
My problem is I can't find a way to update styles heading one and heading
two in the docuement using vba
i assume that wdStyleHeading1 relates to heading1 in document
The rem code was the original search i use for bookmarks.
Any suggestions wil be helpfull
Heres my code :
Sub styles_test()
zero = 0
RecLen = 63
primary = 0
offset = 1
Open "c:\lcc\data\C_contents.txt" _
For Input As #1
Open "c:\lcc\data\C_bookmarks_contents.txt" _
For Input As #2
counter = 0
Rem Do While Not EOF(1)
Do While counter <= 3
Line Input #1, searchstring
Line Input #2, bookmarkfield
Rem Set MyRange = ActiveDocument.Content
Rem MyRange.Find.Execute FindText:=searchstring, Forward:=True
Rem If MyRange.Find.Found = False Then Exit Do
one_byte = Mid(bookmarkfield, 1, 1)
If one_byte <> "_" Then
With Selection.Find
.Forward = True
.ClearFormatting
.Style = wdStyleHeading1
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:=searchfield
End With
Else
With Selection.Find
.Forward = True
.ClearFormatting
.Style = wdStyleHeading2
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:=searchfield
End With
End If
Rem ActiveDocument.Bookmarks.Add Name:=bookmarkfield, Range:=MyRange
Rem ActiveDocument.Bookmarks.ShowHidden = True
Rem MyRange.Bookmarks(counter).Add Name:=bookmarkfield
Rem ActiveWindow.View.ShowBookmarks = True
primenumber = 0
counter = counter + 1
Loop
offset = offset + 1
Close #1
Close #2
End Sub
worked fine. But my intent was to build adobe acrobat pdf with bookmarks and
that just doesn't work.
So now I'm trying to update my searchs with styles that acrobat can regonize
on particular headings I have in my searchfield fiile I bring in.
I decided to use heading1 and heading2 styles in the document. I modified
them to have different format. Thats ok I have on 2 levels (one parent /
child)
My problem is I can't find a way to update styles heading one and heading
two in the docuement using vba
i assume that wdStyleHeading1 relates to heading1 in document
The rem code was the original search i use for bookmarks.
Any suggestions wil be helpfull
Heres my code :
Sub styles_test()
zero = 0
RecLen = 63
primary = 0
offset = 1
Open "c:\lcc\data\C_contents.txt" _
For Input As #1
Open "c:\lcc\data\C_bookmarks_contents.txt" _
For Input As #2
counter = 0
Rem Do While Not EOF(1)
Do While counter <= 3
Line Input #1, searchstring
Line Input #2, bookmarkfield
Rem Set MyRange = ActiveDocument.Content
Rem MyRange.Find.Execute FindText:=searchstring, Forward:=True
Rem If MyRange.Find.Found = False Then Exit Do
one_byte = Mid(bookmarkfield, 1, 1)
If one_byte <> "_" Then
With Selection.Find
.Forward = True
.ClearFormatting
.Style = wdStyleHeading1
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:=searchfield
End With
Else
With Selection.Find
.Forward = True
.ClearFormatting
.Style = wdStyleHeading2
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:=searchfield
End With
End If
Rem ActiveDocument.Bookmarks.Add Name:=bookmarkfield, Range:=MyRange
Rem ActiveDocument.Bookmarks.ShowHidden = True
Rem MyRange.Bookmarks(counter).Add Name:=bookmarkfield
Rem ActiveWindow.View.ShowBookmarks = True
primenumber = 0
counter = counter + 1
Loop
offset = offset + 1
Close #1
Close #2
End Sub