Subject Re: Print Entryfield Editor
From Mervyn Bick <invalid@invalid.invalid>
Date Sat, 23 Apr 2022 15:56:10 +0200
Newsgroups dbase.getting-started

On 2022/04/22 19:28, Norman Snowden wrote:
>   Below is part of the code I used to successfully complete Editor2 and show the
>   results on screen. However, I also want to print the results. When I try to print it, an
>   Error message comes up, " Can't find File plot_occupation.txt".
>   I checked in the program Folder and do find plot_occupation.txt there. If clicked on, it prints out with Notepad and can be sent to the printer for printing. Must be something with word. application?
>
> I realize the entire code would be necessary to find the problem. However, any comments would be appreciated. Thanks, Norman
>
>    Asort(Occup,1)
>              form.editor2.value = ''        
>         fFile = new file()
>         fFile.create('plot_Occupations.txt')
>         crlf = chr(13)+chr(10)
>         form.editor2.value += "  " + crlf
>         form.editor2.value += '   ' +  '                          OCCUPATIONS' + '  ' + crlf                     
>             form.editor2.value +=  "      -------------------------------------------------" //no crlf
>          fFile.puts(form.editor2.value) //fFileputs() adds crlf in file automatically
>          form.editor2.value += crlf  //add crlf to editor contents for proper display
>            
>   function PUSHBUTTON11_onClick()
>        form.entryfield1.value = set('directory')+'\plot_occupation.txt'
>        oWord = new oleAutoclient("word.application")
>        oWord.ChangeFileOpenDirectory( set('directory')+'\')
>        oWord.documents.open("plot_occupation.txt",false, true )
>        oWord.activeDocument.printOut()
>        oWord.quit( 0 )
>        release object oWord
>        oWord = null
>        return

For some reason oWord.ChangeFileOpenDirectory( set('directory')+'\') is
not pointing Word to the right place.

Instead of changing the directory, simply adding the path to the
filename gets around the problem.


        cFile = set('directory')+'\plant_occupation.txt'
        oWord = new oleAutoclient("word.application")
//      oWord.ChangeFileOpenDirectory( set('directory')+'\')
       oWord.documents.open(cFile,false,true)
       oWord.activeDocument.printOut()
       oWord.quit( 0 )
       release object oWord
       oWord = null


Mervyn.