Run a Perl interpreter from Microsoft Word
This VBA gives a subroutine, PerlString
, which runs a
Perl script under a Perl interpreter, here wperl.exe
.
Function PerlString(Script As String, Optional args As String = "") ' Returns a string to pass to Shell in order to run a script. ' Call this with the name of the script to run, ' which should be something in C:\Users\ben\bin, and ' the arguments to the script. Dim ScriptPath As String ScriptPath = "C:\Users\ben\bin\" & Script PerlString = """C:\Perl\bin\wperl.exe""" & _ " """ & ScriptPath & """ """ & args & """" End Function
To run a Perl script called subdates.pl
from VBA, use the
routine with the VBA command Shell as follows:
Sub SubstituteDates() Dim PerlPath As String PerlPath = PerlString("subdates.pl") RetVal = Shell(PerlPath, vbNormalFocus) End Sub
Web links
-
MsOffice::Word::Util
This is a collection of Perl routines which will assist in writing Perl scripts to manipulate the contents of Microsoft Word documents. For example, get the current document, turn it into text, etc.
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com) or use the discussion group at Google Groups.
/
Privacy /
Disclaimer