以下几个自定义函数,可以正常操作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 xlapp nil)
- ;;;(xlr_excel_saveas xlapp 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)
- )
|