简体   繁体   English

VBScript:在MS“ Word” 2003文档中添加一个单词

[英]VBScript: Appending a word to the MS “Word” 2003 document

Here is a short code that opens my "fox.doc" : 这是打开我的“ fox.doc”的简短代码:

Set wd = CreateObject("Word.Application")
wd.Visible = True
Set doc = wd.Documents.Open("c:\fox.doc")

I need to add only one word "bottle" in the end of this document (after it has been opened). 在此文档的末尾(打开后),我只需要添加一个单词“ bottle”。 Which lines should I add to my small vbs script for that? 为此,我应该在小型vbs脚本中添加哪些行?

You can learn a lot by recording macros in Word and then making the, usually small, changes that will make the code work in VBScript. 通过在Word中记录宏,然后进行通常很小的更改,使代码在VBScript中起作用,您可以学到很多东西。

Set r = doc.Words.Last
r.InsertAfter (" bottle")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM