以下几个自定义函数,可以正常操作OFFICE的软件,不能操作WPS的表格,提示实参数少
以下几个自定义函数,可以正常操作OFFICE的软件,不能操作WPS的表格,提示实参数少,请大神们指点一下,谢谢;;;(setq XLSFile "C:\\Users\\Administrator\\Desktop\\测试.xls")
;;;(setq UnHide t)
;;;(xlr_open_xls XLSFile t )
;;;(xlr_open_xls表格路径是否显示)打开表格
(Defun xlr_open_xls( XLSFile UnHide / ExcelApp WorkSheet Sheets ActiveSheet Rtn)
(if (and (findfile XLSFile) (setq Rtn (vlax-get-or-create-object "Excel.Application")))
(progn (vlax-invoke-method (vlax-get-property Rtn 'WorkBooks) 'Open XLSFile)
(if UnHide
(vla-put-visible Rtn 1)
(vla-put-visible Rtn 0)
)
)
)
Rtn
)
;;;(setq XLSFile "C:\\Users\\Administrator\\Desktop\\测试2313.xls")
;;;(xlr_excel_kill xlappnil)
;;;(xlr_excel_saveasxlapp XLSFile)
;;;(xlr_excel_kill xlapp "C:\\Users\\Administrator\\Desktop\\测试2313.xls")
;;;________________________________________________________________________
(Defun xlr_excel_kill (ExlObj SaveYN);;;excel退出与保存
(if SaveYN
(progn
(vlax-invoke-method (vlax-get-property ExlObj "ActiveWorkbook") 'SAVE)
(vlax-invoke-method (vlax-get-property ExlObj "ActiveWorkbook") 'Close :vlax-False)
)
(vlax-invoke-method (vlax-get-property ExlObj "ActiveWorkbook") 'Close :vlax-False)
)
(vlax-invoke-method ExlObj 'QUIT)
(vlax-release-object ExlObj)
(setq ExlObj nil)
(gc)
)
;;;另存文件
(Defun xlr_excel_saveas (xlapp Filename / Rtn)
(if (findfile Filename)
(vl-file-delete (findfile Filename))
)
(vlax-invoke-method
(vlax-get-property Xlapp "ActiveWorkbook")
"SaveAs"
Filename
msxl-xlNormal
""
""
:vlax-False
:vlax-False
nil
)
(findfile Filename)
)
(if (and (findfile XLSFile) (setq Rtn (vlax-get-or-create-object "Excel.Application")))
→→→→→
(if (and (findfile XLSFile) (setq Rtn (vlax-create-object "Excel.Application")))
谢谢
所以解决了吗?把函数:vlax-get-or-create-object改成vlax-create-object。也不行啊 vlax-invoke-method 改为vlax-invoke
(setq Rtn (vlax-get-or-create-object "Excel.Application"))改为
(setq rtn (cond ((vlax-get-or-create-object "ket.application"))
((vlax-get-or-create-object "execl.application"))
)
)
页:
[1]