【VBA】如何在Word表格里插入特殊符号
Word里有插入特殊符号的功能,如下图。
通过编程语言实现在Word表格插入特殊符号操作,可以参考下面VBA代码。
1 2 3 4 | ActiveDocument.Tables(1).Range.Cells(2). Select Selection.MoveEnd Unit:=wdCharacter, Count:=-1 Selection.InsertSymbol Font:= "Wingdings" , _ CharacterNumber:=-4014, Unicode := True |
refer:Insert symbol into cell in table (narkive.com)
扩展一下:
①Unit:=wdCharacter中的unit参数是一个枚举值,在Word以外的程序中使用时可以使用枚举值数值。
refer:WdUnits enumeration (Word) | Microsoft Learn
②在Excel VBA中后期绑定实现该操作需要注意枚举值处理,代码如下:
1 2 3 4 5 6 | '方框选中符号 Sub InsertSelectedSymbolIntoTable(tableIdx As Integer , rowIdx As Integer , colIdx As Integer ) thisDoc.Tables(tableIdx).Cell(rowIdx, colIdx).Range. Select wordApp.Selection.MoveEnd Unit:=1, Count:=-1 'Unit:=wdCharacter wordApp.Selection.InsertSymbol CharacterNumber:=-4014, Font:= "Wingdings 2" , Unicode := True End Sub |
分类:
Office应用及开发
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
2020-05-07 System.DllNotFoundException:“无法加载 DLL“SQLite.Interop.dll”: 找不到指定的模块 的解决方法