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:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to