Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2007

Tip: Looking for answers? Try searching our database.

calling a server-side perl script from within VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary Hillerson - 09 Aug 2007 02:30 GMT
I need to call a server-side perl script provided by someone else from
within my VBA code (in a Word template).

I know nothing about COM.  And this template gets used by people in a
variety of Word/Windows configurations -- Word 2000 or later on
Windows 98 or later.

I can call LaunchURL (from shell32.dll) to open a browser to a web
site. Is there something similar I can use to call a perl script and
get back a result?

thanks in advance,
  gary hillerson
Russ - 12 Aug 2007 17:36 GMT
Gary,
You could call a dos batch file from VBA.
Helmut Weber mentioned this:
<http://vb.mvps.org/samples/project.asp?id=Shell32>

Or this xShell code works in Word97, too:

Put this in Declarations section at the top of your VBA code module so that
all subroutines can take advantage of the 'wait for shell' code.

Private Declare Function CloseHandle Lib "kernel32" ( _
   ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" ( _
   ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" ( _
   ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
   ByVal dwProcessId As Long) As Long

'Add this code as one of the regular subroutines.

Public Function ShellX( _
   ByVal PathName As String, _
   Optional ByVal WindowStyle As Integer = vbMinimizedFocus, _
   Optional ByVal Events As Boolean = True _
 ) As Long

 'Declarations:
 Const STILL_ACTIVE = &H103&
 Const PROCESS_QUERY_INFORMATION = &H400&
 Dim ProcId As Long
 Dim ProcHnd As Long

 'Get process-handle:
 ProcId = Shell(PathName, WindowStyle)
 ProcHnd = OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcId)

 'wait for process end:
 Do
   If Events Then DoEvents
   GetExitCodeProcess ProcHnd, ShellX
 Loop While ShellX = STILL_ACTIVE

 'clean up:
 CloseHandle ProcHnd
End Function

'And call it like this:

  Dim x As Long
  Dim strDosBatchFullPath As String
  strDosBatchFullPath = ³C:\...myDosBatchFile.bat²
  System.Cursor = wdCursorWait
  x = ShellX(Chr(34) & strDosBatchFullPath & Chr(34))

> I need to call a server-side perl script provided by someone else from
> within my VBA code (in a Word template).
[quoted text clipped - 9 lines]
> thanks in advance,
>    gary hillerson

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Gary Hillerson - 25 Aug 2007 03:56 GMT
Hey Russ,

Thanks so much.

I'm just back from vacation, and will stab at this in the next few
days, but it sure makes sense. So thanks again,

gary

>Gary,
>You could call a dos batch file from VBA.
[quoted text clipped - 63 lines]
>> thanks in advance,
>>    gary hillerson

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.