简体   繁体   中英

Add VBA code to a MS Word document using Perl

I have a Perl script that can define and write MS Word VBA according to the user's input.

How can I make the Perl script open Word and add the VBA code into its code data base?

You can do that by accessing the VBProject property of the document. However, with recent versions of Microsoft Office, you will likely get:

OLE exception from "Microsoft Word":

Programmatic access to Visual Basic Project is not trusted.

See You may receive an run-time error when you programmatically allow access KB article for more information.

Or, you can try to do it the primitive way by sending keystrokes to Word using Win32::GuiTest .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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