T
Tywardreath
Hi
I have a piece of VBA code that I'd like to modify, but I really don't know
how. This is the code:
Sub InsertWordCount()
Dim oRange As Word.Range
Dim sBookmarkName As String
sBookmarkName = "WordCount"
With ActiveDocument
Set oRange = .Bookmarks(sBookmarkName).Range
oRange.Delete
oRange.InsertAfter Text:=Format(.Sections(2).Range.ComputeStatistics
(wdStatisticWords), "0")
.Bookmarks.Add Name:=sBookmarkName, Range:=oRange
End With
End Sub
What the code does is that it does a word count on a specific section (in
this case section 2), and then it returns the result into an existing
bookmark called "WordCount".
Somehow I'd like to get the resulting number to be surrounded by another
bookmark (e.g. real). I'd like to do that in the VBA code. Then I have a
formula which will calculate if I am over or under the desired word count.
The formula I hope to use is: {if {real} > 10000 "more than 10000" "less than
10000}.
I'm not fussed if the formula is in the VBA or not.
Appreciate any help that can be offered.
Cheers, Ty.
I have a piece of VBA code that I'd like to modify, but I really don't know
how. This is the code:
Sub InsertWordCount()
Dim oRange As Word.Range
Dim sBookmarkName As String
sBookmarkName = "WordCount"
With ActiveDocument
Set oRange = .Bookmarks(sBookmarkName).Range
oRange.Delete
oRange.InsertAfter Text:=Format(.Sections(2).Range.ComputeStatistics
(wdStatisticWords), "0")
.Bookmarks.Add Name:=sBookmarkName, Range:=oRange
End With
End Sub
What the code does is that it does a word count on a specific section (in
this case section 2), and then it returns the result into an existing
bookmark called "WordCount".
Somehow I'd like to get the resulting number to be surrounded by another
bookmark (e.g. real). I'd like to do that in the VBA code. Then I have a
formula which will calculate if I am over or under the desired word count.
The formula I hope to use is: {if {real} > 10000 "more than 10000" "less than
10000}.
I'm not fussed if the formula is in the VBA or not.
Appreciate any help that can be offered.
Cheers, Ty.