几何尺寸与公差论坛

 找回密码
 注册
查看: 1006|回复: 0

【转帖】arget sheet drawing from excel

[复制链接]
发表于 2009-4-12 22:37:15 | 显示全部楼层 |阅读模式
target sheet drawing from excel
it is possible to target a sheet drawing located under this path c:\test\drawing a.slddrw from excel cells. this drawing file has 40 sheets.
for example, if i type in the cell "a1" sheet1 i want to target the sheet1
if i type in the cell "a1" sheet2 i want to target the sheet2.
i have already the statement to open the sw drawing file. i just want it to target it accordinally my selecting in the excel cell as i mentiond above.
thanks in advance.
maperalia
on your cell value changed event...
swdrawingdoc.activatesheet range("a1")
luke;
thanks for your quick response and the statement. it is working perfectly!!!!!
kind regards.
maperalia
luke;
i so sorry to bother you again. however, i thought the code was running properly. in fact i was using two sheets (sheet1 and sheet11). and i got confuse.
the fact, is the now i have the "sheet 1" and the "sheet 2" in sw drawing. i typed in the cell "a1" "sheet 2" and it is not targeting the sheet selected. it always target the "sheet 1". (see code below as a reference).
kind regards.
maperalia
'@@@@@@@@@@@@@@@@@@@@@@@@@@
set swapp = application.sldworks
set swapp = getobject("sldworks.application")
set part = swapp.activedoc
set drawing = swapp.opendoc("c:\paper\blue.slddrw", swdocdrawing)
swdrawingdoc.activatesheet range("a1")
@@@@@@@@@@@@@@@@@@@@@@@@@@
there are many things wrong with that code segment.
firstly, you attempt to set the swapp using application.sldworks, which will only work from within solidworks macros. then below you try with getobject with a missing syntax so this would not work at all. then you set a variable called drawing to the drawing document, but after try to access a variable called swdrawingdoc. to fix it do this:
dim swapp as sldworks.sldworks
dim drawing as drawingdoc
set swapp = getobject(, "sldworks.application")
set drawing = swapp.activedoc
' or set drawing = swapp.opendoc("c:\paper\blue.slddrw", swdocdrawing)
drawing.activatesheet range("a1")
luke;
thanks very much. the code you sent me is working perfectly!!!!!
kind regards.
maperalia
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 18:39 , Processed in 0.035248 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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