Steve-vfp9user
Programmer
Hello
I am having an issue with what I thought was a straight forward COPY FILE TO requirement. I previously created an automated .doc Word document (no issues there) but if I need to automatically search and copy the .doc file (if it exists) to a dedicated "Jobs" folder, I cannot get this to work.
Here is what I have so far:
I am stumped with this one, I'm sure it's just a minor amendment but I can't see it.
Any suggestions please or what I have missed?
Thank you
Steve Williams
VFP9, SP2, Windows 10
I am having an issue with what I thought was a straight forward COPY FILE TO requirement. I previously created an automated .doc Word document (no issues there) but if I need to automatically search and copy the .doc file (if it exists) to a dedicated "Jobs" folder, I cannot get this to work.
Here is what I have so far:
Code:
mrecno=50 && Using this record number for jobs to test
mqrecno=214 && Using this record for quotes to test
* LONG QUOTE (WORD DOCUMENT) LINKED TO THE JOB
USE MYTABLE SHARED
GO mrecno && I know this record exists
* THE BELOW cPath IS THE PATH WHERE ALL RELATED DOCUMENTS ARE STORED
* THESE ARE JOB SHEETS, QUOTES ETC - THAT'S ALL WORKING
cPath=SYS(2003)+"\"+LTRIM(STR(JOBYEAR))+" jobs\"+LTRIM(STR(JOBNUMB))+"-"+ ;
LTRIM(STR(JOBYEAR))+" "+ALLTRIM(ICOMPANY)+" "+ALLTRIM(JOBTITLE)
USE MYQUOTES SHARED
GO mqrecno
* THIS QUOTE JOB NUMBER IS 12/2022 AND I KNOW IT EXISTS
* QJOBNUMB=12
* QJOBYEAR=2022
* mquotationdoc && The name of the WORD document e.g. Quotation 12-2022 JEFFS COMPANY FIX A WINDOW
* FIELDS ARE:
mquotationdoc="Quotation "+LTRIM(STR(QJOBNUMB))+"-"+LTRIM(STR(QJOBYEAR))+ ;
" "+ALLTRIM(ICOMPANY)+" "+ALLTRIM(JOBTITLE)
* cPathquote && The path where the .doc is saved after being previously automatically generated
cPathquote=SYS(2003)+"\"+LTRIM(STR(QJOBYEAR))+" quotes\"+"Quotation "+LTRIM(STR(QJOBNUMB))+ ;
"-"+LTRIM(STR(QJOBYEAR))+" "+ALLTRIM(ICOMPANY)+" "+ALLTRIM(JOBTITLE)
IF FILE(cPathquote+"\"+mquotationdoc+'.doc')
* I PUT A WAIT WINDOW HERE TO PROVE OR DISPROVE THE FILE EXISTS (IT DOES EXISTS)
WAIT "File yes: "+cPathquote+"\"+mquotationdoc+'.doc' WINDOW
COPY FILE cPathquote+"\"+mquotationdoc+'.doc' TO cPath && [b]FILE IS NOT COPYING TO cPath from cPathquote[/b]
ELSE
WAIT "File no: "+cPathquote+"\"+mquotationdoc+'.doc' WINDOW
ENDIF
I am stumped with this one, I'm sure it's just a minor amendment but I can't see it.
Any suggestions please or what I have missed?
Thank you
Steve Williams
VFP9, SP2, Windows 10