wscript.exe is one way to go.

To learn how to write the particular script for MS Word on Windows, let it
record a macro of what you want to do.
You can pull the macro out into a text file and run it with wscript (with a
few more commands to get Word started and point at the document).
To record a Macro, you can type in "record a macro" in the "Tell me what
you want to do" box.
Or, go to the Views tab and find Macros on the right.

Google is your friend - running VBA macros.

HTH,

Jim





On Sun, Oct 7, 2018 at 6:02 PM Jeremy Roussak via 4D_Tech <
[email protected]> wrote:

> I have an AppleScript which is called from 4D with four numeric
> parameters. Provided MS Word is running and the cursor is in a table, it
> fills columns 2 to 5 of the table with its parameters and tabs out of the
> last column, probably creating a new row in the table.
>
> I’m now called upon to make the 4D application, and hence the script, work
> under Windows. Sadly, and a bit problematically I haven’t a clue about
> scripting Windows. I imagine it can be done in VB. Any help would be most
> gratefully received!
>
> The AppleScript is below.
>
> Thanks
>
> Jeremy
>
> -- paste the arguments into the last four columns of the current table
> -- then tab into the first column, probably creating a new row
> -- called from the periodic multipliers tab
>
> on run argv
>
>         if (WordIsRunning()) then
>
>                 tell application "Microsoft Word"
>
>                         activate
>
>                         if (get selection information selection
> information type with in table) is "true" then
>
>                                 set tTable to selection's table 1
>                                 set rowNum to row index of (selection's
> row 1)
>                                 set colNum to (count tTable's columns) - 4
>
>                                 repeat with i from 1 to 4
>                                         set tCell to text object of (get
> cell from table tTable row rowNum column (colNum + i))
>                                         set tPara to tCell's paragraph 1
>                                         set tPara's text object's content
> to (item i of argv)
>                                 end repeat
>
>                                 set curCol to column index of (selection's
> column 1)
>
>                                 repeat (colNum - curCol + 5) times
>                                         tell application "System Events"
>                                                 keystroke "\t"
>                                         end tell
>                                 end repeat
>
>                         end if
>
>                 end tell
>
>         end if
>
> end run
>
> on WordIsRunning()
>         tell application "System Events"
>                 return (bundle identifier of processes) contains
> "com.microsoft.Word"
>         end tell
> end WordIsRunning
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to