6、如何判断EXCEL或某个XLS文件是否已经打开(避免不可预知的错误发生):
LOCAL lOldSetOpt,mChanNum
lOldSetOpt = DDESetOption("SAFETY")
= DDESetOption("SAFETY",.F.)
mChanNum = DDEInitiate('Excel','SYSTEM')
&&EXCEL是否已经打开
**mChanNum = DDEInitiate('Excel','&lcFileName')
&&lcFileName某XLS文件名,如:D:\123.XLS
IF mChanNum <> -1
= messagebox('程序 EXCEL 已经打开,请先将其关闭!',64,'系统提示!')
**
= messagebox('文件 '+lcFileName+' 已经打开,请先将其关闭!',64,'系统提示!')
= DDETerminate(mChanNum)
= DDESetOption("SAFETY",lOldSetOpt)
RETURN
ENDIF