[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-win32-users
Subject:    Converting this VBScript to perl
From:       Suresh Govindachar<sgovindachar () yahoo ! com>
Date:       2004-08-31 21:21:26
Message-ID: 123slf56ljfs1093987286 () tms-eui ! org
[Download RAW message or body]

=head

Hello,

Given below is a VBScript;  how do I go about converting 
it to perl?

But first here's the background on how I got this script
and what it does.  I asked the following question on a 
word97vba newsgroup:

>
> I would like to use Word's Thesaurus from an application
> outside Word.  The application will have a word that it
> wants to look up in the Thesaurus.
>
> 1) Is there any sample code that shows how the application
>    can feed this look-up word to Word's Thesaurus engine
>    and collect the matches?
>
> 2) If the preceding cannot be done, can the application
>    pop-up Word's Thesaurus dialog box with the word to be
>    looked up already filled in and without starting MS
>    Word?  Sample code?
>
> 3) If the preceding cannot be done, can the application
>    bring-up Word, and then pop-up Word's Thesaurus dialog
>    box with the word to be looked up already filled in?
>    Sample code?
>
A person, Chad DeMeyer, was kind and skilled enough to
promptly create, test and provide me with the VBScript.
Also, he remarked that:

   For demonstration purposes, I used InputBox to get the
   word and MsgBox to display the replacement.  If you were
   programming this from another application, you should be
   able to get the string from whatever is selected and
   replace that with the results of the synonym check.  You
   could also validate that only a single word is selected,
   or check each selected word separately by building an
   array of the words using the Split function.  You might
   also want to test whether any synonyms were actually
   selected before replacing the original selection.

Now here's his VBScript which I would like to have in perl 
(when there are multiple matches, I would like to receive
all of them).  

By the way, the next step would be to provide a string
representing a sentence to Word's spell/grammar checker
and get the result of the check inside perl.

'-------------------------------------------------
Dim sText
Dim oWord
Dim oDoc
Dim lOrigTop
Dim oRng

sText = InputBox("Please type the word to look up:", "Look Up Synonym")

' Create a Word document object...
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add

' Position Word off screen to avoid having document visible...
lOrigTop = oWord.Top
oWord.WindowState = 0

'oWord.Top = -3000
' Assign the text to the document and check synonyms...
With oDoc
            .Activate
            With .Range
                        .InsertBefore sText
                        .CheckSynonyms
                        sText = .Text
            End With
            ' Close the document and exit Word...
            .Saved = False
            .Close (0)
End With

Set oDoc = Nothing
With oWord
            .Visible = False
            .Top = lOrigTop            'restore Word Window to original
location
            .Quit
End With

Set oWord = Nothing
MsgBox "Replacement word is:" & vbCr & vbCr & sText
'-------------------------------------------------

=cut
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic