几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 08:52 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】excel question

excel question
i have a macro that accesses an excel sheet for part numbers then copies those drawings from the pdm vault. the program works fine except when i am editing the excel sheet and i run my macro. i think because excel is in "edit mode" my macro hangs and finally gives me a message to go to excel and fix my problem. just clicking in another cell fixes my problem.
is there a code that i can use to check to see if excel is in edit mode and create my own error message, or better yet, just take excel out of edit mode?
thanks
dan miel
why comes excel in edit mode?
macro is starting excel, opening sheet, reading cells, doing something with values and closing excel?
hi ivana
the macro does not open excel it just grabs whatever is opened. this macro is written because purchasing would send us list of drawings needed in excel sheets and i was to lazy to type everything into pdmworks to get the drawings, so i wrote this to grab whatever excel is opened and get the files from the vault. i found that when i need to get even one file, it is faster to start an excel file, type the part/s and click the macro button rather than doing searches in the vault. therefore the problem, if i forget to press "enter" or click in another column before i start the macro it thinks i'm still editing the cell.
i have tried using sendkey to send an enter to excel and tried changing the active cell to another cell but if i haven't pressed enter before i start the macro it still hangs.
the code below is similar to my connection and getting the first cell. i'm using an excel 11 reference. if you edit the first cell and run the macro without pressing enter it should hang for a little bit and then tell you that the sever is busy.
dan miel
sub main()
dim xldoc as excel.application
dim filename as string
set xldoc = getobject(, "excel.application")
filename = xldoc.sheets(1).cells(1, 1)
debug.print filename
end sub
and if you do the same trick with word?
sub main()
dim objword as word.application
dim objdoc as word.document
dim s as variant
dim s1() as variant
on error resume next
set part = swapp.activedoc
set objword = getobject(, "word.application")
set objdoc = objword.activedocument
s = objdoc.content.text
s1 = split(s, chr(13))
for each s in s1
debug.print trim(s)
next s
end sub
i tried "resume next" the other day and it still hangs.
dan
no, i mean if you use microsoft word - each row one drawing code - try it with my code above.
for excel edit mode is no solution within vba. you can only do something in vb.
resume next would'nt help. i had to clean it. it is used only if you want resuse word session and if you don't have one, then create new one.
edited: 02/28/2009 at 02:30 pm by ivana kolin
ivana
the code works nicely. i have not used word before and didn't recognize what your code was intended to do. my macro writes back to the excel sheet what it finds, drw, assm, part and missing or obsolete parts so i will need to change how it reports those things, but i like the way that word does not hang up.
thanks
dan miel
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 09:54 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多