Excel中SymbolInsert内置函数字体异常问题求助
Excel SymbolInsert 插入Wingdings数字编码字符时字体自动重置问题
问题详情
Excel版本:2104 build 13929.20254
单元格初始字体为Arial,使用内置的SymbolInsert工具插入Wingdings字体字符时出现异常:
- 插入常规文字范围的Wingdings字符,单元格字体自动变为Wingdings(符合预期)
- 插入字符编码48-57(对应常规数字0-9的编码位)的Wingdings字符,关闭SymbolInsert窗口时单元格内显示正常,但离开单元格后字体自动重置为Arial
触发该问题的宏代码:
With Application .CommandBars.ExecuteMso "SymbolInsert" .SendKeys "{TAB}", True End With
解决方案
方案1:直接用VBA插入带指定字体的字符(推荐)
绕过SymbolInsert的内置格式冲突,直接通过代码插入字符并强制设置字体,确保格式不会被重置:
Sub InsertWingdingsSymbol() Dim targetCell As Range Set targetCell = ActiveCell ' 替换Chr(48)为你需要的编码(48-57),比如Chr(49)对应Wingdings的另一个符号 Dim symbolChar As String symbolChar = Chr(48) ' 在单元格末尾插入字符 targetCell.Characters(Start:=targetCell.Characters.Count + 1, Length:=1).Text = symbolChar ' 给插入的字符设置Wingdings字体 targetCell.Characters(Start:=targetCell.Characters.Count, Length:=1).Font.Name = "Wingdings" End Sub
方案2:调整Excel自动格式设置
检查是否有自动格式规则导致数字编码字符强制恢复默认字体:
- 打开「文件」→「选项」→「校对」→「自动更正选项」→「自动格式」选项卡
- 取消勾选可能影响的自动替换规则(比如与数字格式相关的选项)
- 同时检查单元格是否设置了条件格式,排除条件格式导致的字体重置
方案3:插入后强制补设字体
如果必须使用SymbolInsert窗口操作,可在用户完成插入后,通过代码为最后插入的字符强制设置字体:
Sub InsertSymbolAndFixFont() ' 调用SymbolInsert窗口 With Application .CommandBars.ExecuteMso "SymbolInsert" .SendKeys "{TAB}", True End With ' 等待用户完成插入操作(这里设置2秒延时,可根据实际调整) Application.Wait Now + TimeValue("00:00:02") Dim targetCell As Range Set targetCell = ActiveCell ' 给单元格最后一个字符设置Wingdings字体 If targetCell.Characters.Count > 0 Then targetCell.Characters(Start:=targetCell.Characters.Count, Length:=1).Font.Name = "Wingdings" End If End Sub
问题原因
这是Excel的内置逻辑:当识别到插入的字符编码属于0-9的数字范围(48-57)时,会默认将其视为普通数字,自动应用单元格的基础字体(Arial),忽略SymbolInsert窗口中选择的Wingdings字体设置。
内容的提问来源于stack exchange,提问作者iFuraon
相关产品推荐
相关产品推荐

