A
Anna Neiderud
Hi,
I have a problem with InsertSymbol that I have seen nowhere else. I need to
insert a character from a symbol font and want it to have symbol behaviour,
i.e. if I mark a range containing the character afterwards and select another
font, the symbol character won't change. This might sound simple and I
thought it was, but generally it doesn't work the first few times...
In a fresh Word application I use the code below to insert a symbol
character with some other symbol font than Symbol and the first and sometimes
first few character will be wrong:
Sub InsertWayPointerSymbol()
Dim rng As Range
Dim i As Long
Set rng = Selection.Range.Duplicate
For i = 0 To 30
rng.InsertSymbol AscW("n"), "Marlett"
rng.MoveEnd wdCharacter
rng.Font.Name = "Times New Roman"
rng.Collapse wdCollapseEnd
Next i
End Sub
I assume this has something to do with the font not being fully initialized
before I start, but can I force it to be somehow?
I tried simply inserting one character and removing it first, but the
problem is I do not know how many times I need to fix it. On some users
machines the problem occurs for a longer time.
Would I be guaranteed that it will work if I add a style containing the
symbol font to the template that is used? Or can I programmatically create a
style or something to force the font to be initialized?
For readers familiar with WordML it might be helpfull to see the difference
in wordml between the incorrect and correct character:
Incorrect:
<w:r>
<w:rPr>
<w:rFonts w:ascii="Marlett" w:h-ansi="Marlett" />
<wx:font wx:val="Marlett" />
<wx:sym wx:font="Marlett" wx:char="F06E" />
</w:rPr>
<w:t>n</w:t>
</w:r>
Correct:
<w:r>
<w:rPr>
<w:rFonts w:ascii="Marlett" w:h-ansi="Marlett" />
<wx:font wx:val="Marlett" />
</w:rPr>
<w:sym w:font="Marlett" w:char="F06E" />
</w:r>
Greatful for any suggestions!
/Anna
I have a problem with InsertSymbol that I have seen nowhere else. I need to
insert a character from a symbol font and want it to have symbol behaviour,
i.e. if I mark a range containing the character afterwards and select another
font, the symbol character won't change. This might sound simple and I
thought it was, but generally it doesn't work the first few times...
In a fresh Word application I use the code below to insert a symbol
character with some other symbol font than Symbol and the first and sometimes
first few character will be wrong:
Sub InsertWayPointerSymbol()
Dim rng As Range
Dim i As Long
Set rng = Selection.Range.Duplicate
For i = 0 To 30
rng.InsertSymbol AscW("n"), "Marlett"
rng.MoveEnd wdCharacter
rng.Font.Name = "Times New Roman"
rng.Collapse wdCollapseEnd
Next i
End Sub
I assume this has something to do with the font not being fully initialized
before I start, but can I force it to be somehow?
I tried simply inserting one character and removing it first, but the
problem is I do not know how many times I need to fix it. On some users
machines the problem occurs for a longer time.
Would I be guaranteed that it will work if I add a style containing the
symbol font to the template that is used? Or can I programmatically create a
style or something to force the font to be initialized?
For readers familiar with WordML it might be helpfull to see the difference
in wordml between the incorrect and correct character:
Incorrect:
<w:r>
<w:rPr>
<w:rFonts w:ascii="Marlett" w:h-ansi="Marlett" />
<wx:font wx:val="Marlett" />
<wx:sym wx:font="Marlett" wx:char="F06E" />
</w:rPr>
<w:t>n</w:t>
</w:r>
Correct:
<w:r>
<w:rPr>
<w:rFonts w:ascii="Marlett" w:h-ansi="Marlett" />
<wx:font wx:val="Marlett" />
</w:rPr>
<w:sym w:font="Marlett" w:char="F06E" />
</w:r>
Greatful for any suggestions!
/Anna