“打印”按钮的CLICK事件代码修改为下列代码,提示“你选择的文档不存在!!!”,望高手赐教!
SET TALK OFF
SET SAFETY OFF
SET COMPATIBLE OFF
cCurrentProcedure = SYS(16,1)
nPathStart = AT(":",cCurrentProcedure)- 1
nLenOfPath = RAT("\", cCurrentProcedure) - (nPathStart)
mypath=SUBSTR(cCurrentProcedure, nPathStart, nLenofPath)
SET Default TO (mypath)
IF EMPTY( )
MESSAGEBOX('请选择要打印的文档!!!',64,'提示:')
RETURN
ENDIF
wjm=ALLTRIM()+'.'+ALLTRIM(cywj.文件类型)
*IF !FILE(mypath+'\'+wjm)
IF !FILE(ALLTRIM(cywj.路径)+'\'+wjm)
MESSAGEBOX('你选择的文档不存在!!!',64,'提示:')
&&& DBF中录入的名称与实际不符时有用
RETURN
ENDIF
DO case
CASE ALLTRIM(cywj.文件类型)=='doc' OR ALLTRIM(cywj.文件类型)=='docx'
wordapp=CREATEOBJECT("word.application")
wordapp.visible=.t.
* wordapp.application.documents.open(mypath+'\'+wjm)
wordapp.application.documents.open(ALLTRIM(cywj.路径)+'\'+wjm)
wordapp.ActiveDocument.PrintOut
wordapp.quit
RELEASE wordapp
CASE
ALLTRIM(cywj.文件类型)=='xls' OR ALLTRIM(cywj.文件类型)=='xlsx'
oExcel=CREATEOBJECT("excel.application")
oExcel.workbooks.open(ALLTRIM(cywj.路径)+'\'+wjm)
oExcel.visible=.t.
*oExcel.Activeworkbook.PrintPreview
oExcel.Activeworkbook.PrintOut()
oExcel.quit
RELEASE oExcel
ENDCASE
thisform.refresh
RETURN