Word利用宏进行批处理翻译提示“编译错误:过程太大”

H4Rr7 2020-04-28 04:06:48
因为需要进行批处理翻译,需要对特殊样式的专业词汇进行替换。于是我去录制了宏,得到如下代码


Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Mercury Accumulation"
.Replacement.Text = "Mercury Accumulation^p汞元素聚积"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.Find.Execute


可问题是词库太大了,如果全部都写如一个宏中,就无法执行,因为Office宏在编译时,一个过程的代码不得超过 6.4 万个字符。

所以下一步是需要我把词库存在一个Excel表里,然后调用吗?小白很迷茫
...全文
313 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zara 2020-04-29
  • 打赏
  • 举报
回复
放文本文件也可以啊,一行行地读入,处理,进行替换

6,210

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office应用
社区管理员
  • Microsoft Office应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧