Anders,
Thanks for the advice. Your suggestion does all that I need :)
Willie
--- In thecredit@yahoogroups.com, "aklinting" <ank@d...> wrote:
> Hi
> I have done this differently:
>
> Under Options|Tools... create one called
> "Run script"
>
> set command : cscript.exe
> Arguments : $(FilePath)
>
> Check : "Prompt for arguments" and "Redirect to output Window"
> And choose "Active File only" under Save file before running this
> tool"
>
> I furthermore have assigned F5 (under Options|Keyboard...) to run
> this tool.
> This will runn your script and redirect your output to the output
> pane (plus allow you to specify command line arguments).
>
>
> Anders
> --- In thecredit@yahoogroups.com, willie@a... wrote:
> > I have modfied the "Save&Run" macro (that is available from the
> > CREdit website), to allow it to display the output of the
> > executed "script" in the output pane.
> >
> > To do this correctly I need to wait for the script to complete,
and
> I
> > therefore use a loop which contains a "Sleep" to do this.
> > Unfortunately though I can't seem to access the Sleep() method of
> the
> > implicit WScript object.
> >
> > The macro is listed below. Does anyone have any ideas what I am
> > doing wrong?
> >
> > Thanks,
> >
> > Will
> >
> > ' Begin script listing
> > Sub SaveAndRunScript
> > Dim objExec
> >
> > ' change current dir to the active document's directory.
> > Application.CurrentDirectory = ActiveDocument.Path
> >
> > 'Save Without Prompt only if file changed.
> > If ActiveDocument.Saved = False Then ActiveDocument.Save
> > ActiveDocument.FullName,False
> >
> > ' Write to output pane the name of the script that is being
> > run
> > Application.PrintToOutputWindow NOW() & " Starting " &
> > ActiveDocument.FullName
> >
> > Set WshShell = CreateObject("Wscript.Shell")
> >
> > 'Put " around file name in case it contains spaces.
> > Set objExec = WshShell.Exec("cscript.exe" & " " & chr(34) &
> > ActiveDocument.FullName & chr(34))
> >
> >
> > Do While objExec.Status = 0
> > Sleep(100)
> > 'WScript.Sleep(100) -- fails aswell
> > Loop
> >
> > ' Write the scripts StdOut to the output pane
> > Application.PrintToOutputWindow objExec.StdOut.ReadAll()
> > Application.PrintToOutputWindow objExec.StdErr.ReadAll()
> >
> > End Sub