VBScript for Word document automation

0 Votes

VBScript for Word document automation

I have a VBScript that handles the generation of multiple Word documents. It opens a Word Template with form fields and Mail Merge REF fields. The REF fields point to the bookmark of one of the form fields.

I have the form fields marked as "Calculate on Exit" so that the Ref fields are automatically updated if the template is protected. However, Word requires keyboard input for this to work. If the template is not protected, each ref field has to be selected and updated manually.

We want the user to have as little contact as possible with the content of the document. Is it possible, through VBScript, to either simulate keyboard input in the word document (to simulate the "Tab" key being hit to exit the field) or to update the Ref fields?

Thanks for your help.
0 Votes
Collapse -


Vbscript supports sending of keystrokes by using the SendKeys Method. First you need to activate the application you want to send the keystrokes to by using the AppActivate method.
I have loaded an example for you at using this url:

Best Regards,
Marty Lindsay