M
MKruer
The macro is very simple. I want to find the font size other then
default and insert a tag before and after the text to list the font
size.
I am running into two issues
First, getting the default font size for the document.
Second, I think I broke my current script and I can't figure out
where it went wrong LOL.
Any help would be appreciated.
-TIA-
default and insert a tag before and after the text to list the font
size.
I am running into two issues
First, getting the default font size for the document.
Second, I think I broke my current script and I can't figure out
where it went wrong LOL.
Any help would be appreciated.
-TIA-
Code:
Private Sub ConvertSize()
Dim fSize&
If convertFontSize = False Then Exit Sub
If DefaultFontSize = 12 Then DefaultFontSize = 12
fSize = 12
For fSize = 1 To 50
If fSize > DefaultFontSize + 1 Or fSize < DefaultFontSize - 1 Then
'at least two points difference
ActiveDocument.Select
With Selection.Find
.ClearFormatting
.Font.Size = fSize
.Text = ""
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Forward = True
.Wrap = wdFindContinue
Do While .Execute
With Selection
If Len(.Text) > 1 And InStr(1, .Text, vbCr) Then
' Just process the chunk before any newline
characters
' We'll pick-up the rest with the next search
.Collapse
.MoveEndUntil vbCr
End If
' Don't bother to markup newline characters
(prevents a loop, as well)
If Not .Text = vbCr Then
If fSize = DefaultFontSize Then
.InsertBefore "[size=" & fSize & "]"
.InsertAfter "[/size]"
End If
End If
If useDefaultStyle Then .Style =
ActiveDocument.Styles(DefaultStyleName) 'must be localized to your
language, see CONST on top
.Font.Size = DefaultFontSize
'.Collapse wdCollapseEnd
'.MoveLeft , 4, True
'ClearFormatting
End With
Loop
End With
End If
Next
End Sub