大家好。。。
我离开这个网站已经很长时间了,但我希望还有几张热门照片:-)
我的任务是编写一个程序,从AutoCAD中提取属性并将其自动导出到excel中,虽然我的程序可以运行,但在将信息推送到excel之前,我无法让它设置活动工作表。相关代码片段如下。。。。
- (vl-load-com)
- (setq tlbfile (findfile "C:\\Program Files\\Microsoft Office 15\\root\\office15\\Excel.exe"))
- (vlax-import-type-library :tlb-filename tlbfile :methods-prefix "msxl-" :properties-prefix "msxl-" :constants-prefix "msxl-")
- (setq xfile "c:\\attext_test.xls")
- (cond
- ((setq fn (findfile xfile))
- (cond
- ((setq appsession (vlax-get-or-create-object "Excel.Application"))
- (vlax-invoke-method (vlax-get-property appsession 'workbooks) 'open fn)
- (vla-put-visible appsession 0)
- )
- )
- )
- (t (alert (strcat "nCannot locate source file: " xfile)))
- )
- (setq xlapp appsession)
- (msxl-Activate (vla-Item (msxl-Get-WorkSheets xlapp) "Instrumentation"))
- (setq rng (msxl-get-activesheet xlapp))
最后一行的第二行应该将活动页面设置为excel文件中的“Instrumentation”,但它没有。
谁能看出我做错了什么?我将发布整个程序供人们使用,只要我把这个排序(加上下一个程序,将信息从excel推回到autocad属性)
致以最诚挚的问候和感谢
太空猪62 |