明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2446|回复: 4

[提问] 用vlisp打开excel,路径只能用绝对路径吗?

[复制链接]
发表于 2017-9-7 21:01:22 | 显示全部楼层 |阅读模式
本帖最后由 lanyf 于 2017-9-7 21:12 编辑

利用vlisp打开excel,然后存储数据
打开的excel的路径只能用绝对路径吗?
  1. (setq xl (vlax-get-or-create-object "Excel.Application"))
  2. (setq wbs (vlax-get-property xl "WorkBooks"))
  3. (setq wb (vlax-invoke-method wbs "open" excelFile)) ;;excelFile,必须写绝对路径吗?支持路径下,写相对路径可以吗?

比如cad的支持路径为:C:\Program Files\Autodesk\lsp在该路径下面,有个template的文件夹,在该文件夹里有个tt.xls的文件,如何打开tt.xls这个文件呢?
能直接(setq wb (vlax-invoke-method wbs "open" “template\\tt.xls”))吗?
 楼主| 发表于 2017-9-9 19:53:41 | 显示全部楼层

这个是用的绝对路径
问题已经解决
先利用(findfile  文件名)将放在支持的路径下的文件的路径名找出来
就可以了
回复 支持 1 反对 0

使用道具 举报

发表于 2017-9-8 22:15:40 | 显示全部楼层
()
  1. (setq file "C:\\Program Files\\Autodesk\\lsp\\template\\tt.txt")
  2.   (setq readfile(open file "r"))
  3.   (setq readtxt(read-line readfile))
发表于 2017-9-9 09:00:59 | 显示全部楼层
学习一下我顶
发表于 2024-10-17 17:14:53 | 显示全部楼层
(vlax-invoke-method (vlax-get-property (vlax-get-or-create-object "Excel.Application") "WorkBooks") "open" (findfile "图纸目录.xlsm"))    其中"图纸目录.xlsm"在cad的默认搜索路径内
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-22 05:26 , Processed in 0.137889 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表