脚本Word文档中更改字体 [英] Script for changing fonts in a Word document

查看:249
本文介绍了脚本Word文档中更改字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Word 2007的文件,我想改变Courier New字体的所有使用到
A龙力控制台字体。我需要一个脚本,发现该字体格式的所有单词并将其更改为新的字体。



我怎么能这样做?


< DIV CLASS =h2_lin>解决方案

在Word中,你可以做自己录制宏。然后你打开VBA编辑器,有选择地删除一些无用的东西(通常在文件中太多的选择或移动)和你有你的脚本



编辑:移动在这里留言,内容回答笔者的评论。



在录制宏,查找内部和替换对话框中,点击全部替换。然后停止录制。生成的宏是这样的:

  Selection.Find.ClearFormatting 
Selection.Find.Replacement.ClearFormatting
随着Selection.Find
。文本=TARTE太子港POMME
.Replacement.Text =T辅助pruneaux
.Wrap = wdFindContinue
.MatchCase =假
删除了一些东西,
端用
Selection.Find.Execute替换:= wdReplaceAll

从这一点,你可以创建的VBScript宏。你需要得到对象浏览器wdReplaceAll和wdFindContinue的价值。


I have a Word 2007 file and I want to change all usage of the Courier New font into a Lucida Console font. I need a script that find all words formatted in that font and change it to the new font.

How can I do that?

解决方案

Inside Word, you can record a macro by doing it yourself. Then you open the VBA editor, optionally remove some useless thing (usually too many selections or moves within the file) and you've got your script.

Edited: moved the contents of a comment here, to answer the author's comment.

When recording the macro, within the find and replace dialog, click on 'Replace All'. Then stop recording. The generated macro looks like:

Selection.Find.ClearFormatting 
Selection.Find.Replacement.ClearFormatting 
With Selection.Find 
  .Text = "tarte au pomme" 
  .Replacement.Text = "t aux pruneaux" 
  .Wrap = wdFindContinue 
  .MatchCase = False 
  ' removed some stuff 
End With 
Selection.Find.Execute Replace:=wdReplaceAll 

From that, you can create the VBScript macro. You need to get the value of wdReplaceAll and wdFindContinue in the Object Browser.

这篇关于脚本Word文档中更改字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆