简体   繁体   English

如何创建批处理脚本以查找和替换多个文档中的页面

[英]How to create a batch script to find and replace pages within multiple documents

I have created several Word Templates and Forms (over 100). 我创建了几个Word模板和表格(超过100个)。 If any form in a template changes, all like forms in other templates must be updated as well. 如果模板中的任何表单发生更改,则其他模板中的所有相似表单也必须更新。 For example, if another field is added to the form, then I need to update 100 templates with this same added field. 例如,如果将另一个字段添加到表单,那么我需要使用此相同的添加字段来更新100个模板。 So, let's say the templates are saved according to client: 因此,假设模板是根据客户端保存的:

Q://Master Templates/Client Name/Client Template

(Note, the client template may have about 30 or more pages - like a contract and the form might be page 29 in this client, but another client may have 60 pages and the form might be page 20). (请注意,客户端模板可能有约30个或更多页面-像合同,该客户端中的表单可能是第29页,但另一个客户端可能有60页,并且表单可能是第20页)。

Then, there is another folder where the form is a standalone form, or part of a group of forms that are used together. 然后,在另一个文件夹中,该表单是独立表单,或者是一起使用的一组表单的一部分。 Example: 例:

Q://Master forms/Group Forms
Q://Master forms/Standalone Forms

First question: would it make sense to have a batch script that finds the form in each template or each folder; 第一个问题:使用批处理脚本在每个模板或每个文件夹中查找表单是否有意义? and then should the script find add replace the extra field, or does it make more sense to replace the entire form in the templates? 然后脚本应该找到add来替换多余的字段,还是替换模板中的整个表单更有意义?

Second question: how would / could I do this? 第二个问题:我将/如何做? Is there a way to write the script to replace the form in each location based on the example above? 根据上面的示例,是否可以编写脚本来替换每个位置的表单?

Third question: what types of security risks or problems such a batch script can create for an enterprise-wide network? 第三个问题:这样的批处理脚本可以为企业范围的网络带来哪些类型的安全风险或问题?

Thank you in advance for your support. 预先感谢您对我们的支持。

Probably the best answer is to use the Developer ribbon in Word. 最好的答案可能是在Word中使用Developer功能区。 Within Word, File > Options > Customize Ribbon > Check the Developer item under Main Tabs. 在Word中,依次选择“文件”>“选项”>“自定义功能区”>“检查主选项卡”下的“开发人员”项。

Next, open one template needing changes and click Record Macro then make your changes. 接下来,打开一个需要更改的模板,然后单击“记录宏”,然后进行更改。

Now you can open (In Windows Explorer, ctrl + click then right click to open multiple files) the other templates needing the changes and replay the macro to make those changes. 现在,您可以打开(在Windows资源管理器中,按住Ctrl并单击然后右键单击以打开多个文件)其他需要更改的模板,然后重播宏以进行那些更改。

You could even record opening another document then just add the VBA code to open the other templates and play back the recorded macro to make the changes. 您甚至可以记录打开另一个文档的过程,然后只需添加VBA代码即可打开其他模板,然后播放记录的宏以进行更改。

Here's the VBA to open a document in Word. 这是在Word中打开文档的VBA。

ChangeFileOpenDirectory "C:\Users\Administrator\Documents\"
Documents.Open FileName:="My File.docx"

Now once you get at least something partial, post back and we can help refine that. 现在,一旦您至少获得部分内容,请回发,我们可以帮助您完善它。

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

相关问题 批处理脚本查找和替换 - Batch script find and replace 如何在批处理脚本中查找和替换文件内容 - How to Find and Replace file content in batch script 如何使用Windows批处理脚本在“,”中查找和替换文本文件中的“=”? - How to find and replace “=” in a text file with “,” using windows batch script? batch script替换string中的变量字符串 - batch script replace variable string within string 批处理脚本 - 在一个目录中的多个文件中查找和替换文本,而不要求用户安装任何程序或将其他文件添加到我的批处理脚本中 - Batch Script - Find and replace text in multiple files in a directory without asking user to install any program or add other files to my batch script 内部循环查找和替换[批处理脚本] - Find and Replace inside for loop [batch script] 批处理脚本替换多个文件中的特定字符串 - Batch script to replace specific string in multiple files 如何在Windows中编写批处理脚本以循环文件,查找模式并替换它 - How to write a batch script in windows to loop over files , find a pattern and replace it 在Windows批处理脚本中使用FOR LOOP创建多个文件 - Create multiple files with FOR LOOP in windows batch script 查找直到该行,然后用另一个文本文件Windows批处理脚本替换 - Find until that line and replace with another text file windows batch script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM