Hello all,
I'm having a nightmare with coding Word formatting. Here is the story:
- Our Word documents are uploaded to a custom-built software that at the moment reads the underlying "Asian text font", rather than the Font or Complex Font of all text. Once this software spits it out, the formatting is all over the place since it is based on the Asian text font, rather than the real font.
- N.B. half of the documents we're getting are coming from computers that seem to be from Chinese and Korean computers (even though the text is almost always in English or Russian).
- Since it is not possible to set Asian Text Font to Times New Roman, nor to remove the Asian text font altogether, the plan is to Clear all formatting, which seems to wipe the underlying Asian text font.
- The issue is, however, that we need to keep the bold in the original document. The solution we came up with is to search through the document for any instances of bold, strip the formatting, and then reintroduce the bold.
- The code below goes through removing the bold, but I want it also to clear the clearformatting sufficiently well to completely wipe the underlying "Asian text font". Here is what I have. This code only does it for one instance of bold at a time. How do I get it to loop through and do it for all instances? Any help is so much appreciated!!
This was my original attempt
Selection.ClearFormatting
With Selection.Find
.ClearFormatting
.Font.Bold = True
.Replacement.ClearFormatting
.Replacement.Font.Bold = False
.Forward = True
.Wrap = wdFindContinue
.Format = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
And then I tried this
Dim iCount As Integer
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Font.Bold = True
.Execute
End With
Do While Selection.Find.found = True And iCount < 1000
iCount = iCount + 1
If Selection.Find.found Then
Selection.ClearFormatting
Selection.Font.Bold = True
End If
Loop
End Sub