| Subject |
Re: Print Entryfield Editor |
| From |
Norman Snowden <duluth@msn.com> |
| Date |
Sun, 24 Apr 2022 01:02:47 -0400 |
| Newsgroups |
dbase.getting-started |
Norman Snowden Wrote:
> Mervyn Bick Wrote:
>
> > 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.
>
> Mervyn, for some reason even with the change, the same error message occurs. It still sends the txt file to the main program folder rather than the word document. It does'nt make sense. I want to thank you for previously showing me how to use the entryfield Editor to write code and the word. application to print. A previous program using that code still runs fine and prints out OK. As stated, I used that code for this new program.
> Again, thanks Norman
>
Mervyn, I apologize for stating your code did not fix the problem. The fault was that I had an unbelievable mispelling in one the txt files. Glad to see no error message now.
The file now prints normally once, however if the print button is clicked a second time it tries to respond but times out. If the program is closed and reopened it will print normally again. I guess my computer does not like the procedure or maybe there is a memory problem. In any event success is welcomed. Thanks, Norman
|
|