马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 dcl1214 于 2021-8-21 22:09 编辑
- (Defun vlxls-app-saveas
- (xlapp Filename quit? lst / Rtn save kzm wjm f wb)
- ;保存工作薄
- (if (and xlapp
- (setq wb (vl-catch-all-apply
- 'vlax-get-property
- (list xlapp 'activeworkbook)
- )
- )
- (not (vl-catch-all-error-p wb))
- )
- ()
- (setq xlapp (vl-catch-all-apply
- (function (lambda () ($xlapp-New$ 0 t nil)));$xlapp-New$晓东将首尾美元符号给删除了,自己加上
- )
- )
- )
- (setq wb (vl-catch-all-apply
- 'vlax-get-property
- (list xlapp 'activeworkbook)
- )
- )
- (OR (and Filename
- (setq kzm (vl-filename-extension Filename))
- (wcmatch kzm "[,*.xls,*.XLS,]")
- ) ;扩展名
- (SETQ KZM ".xls")
- )
- (or (and Filename
- (setq wjm (vl-filename-base Filename))
- (> (strlen wjm) 0)
- )
- (setq wjm "data")
- )
- (or (and Filename
- (setq f (vl-filename-directory Filename))
- (setq f (vl-string-right-trim "\\" f))
- )
- (and (setq f (getvar "dwgprefix"))
- (setq f (vl-string-right-trim "\\" f))
- )
- )
- (setq Filename (strcat f "\\" wjm kzm))
- (vl-catch-all-apply
- 'vlax-put-property
- (LIST xlapp 'DisplayAlerts :vlax-False)
- ) ;保存的时候不弹出警告的窗口
- (setq save (vl-catch-all-apply
- (function (lambda ()
- (vlax-invoke-method
- wb "SaveAs" Filename
- msxlc-xlNormal ""
- "" :vlax-False :vlax-False
- nil
- )
- )
- )
- )
- )
- (if (vl-catch-all-error-p save)
- (progn (setq save nil)
- (setq Filename (vl-filename-mktemp Filename))
- (setq save (vl-catch-all-apply
- (function (lambda ()
- (vlax-invoke-method
- wb "SaveAs"
- Filename msxlc-xlNormal
- "" ""
- :vlax-False :vlax-False
- nil
- )
- )
- )
- )
- )
- )
- )
- (if quit?
- (progn
- (vlax-invoke-method
- (vlax-get-property xlapp 'activeworkbook)
- 'Close
- )
- (vlax-invoke-method xlapp 'Quit)
- )
- )
- (if (vl-catch-all-error-p save)
- nil
- (findfile Filename)
- )
- )
|