几何尺寸与公差论坛

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

【转帖】runtime error 9

[复制链接]
发表于 2009-4-13 14:01:53 | 显示全部楼层 |阅读模式
runtime error 9
a user recently downloaded a macro and could not run due to "runtime error 9". i have not been able to trace a cause. other users have downloaded and used same program w/ no issues.
any ideas?
tools->references... remove all sw references and re-add. always the first thing to try. if not give me a link to the macro and i will try it out
references were re-added in the new "2007" version.
roland,
not sure if i downloaded the correct file, but "deletecustominfo-2007.zip i get the same runtime error. in looking at the sub main() i see where you have a set swapp = createobject("sldworks.application"). since this is a macro, it should be set swapp = application.sldworks. this is what makes me thing this is the wrong file. this macro should not run on any machine.
wayne matus
texas engineering systems
it's running fine on six different machines here.
wayne: if you have the time, see what happens when you change that line.
edited: 05/16/2008 at 01:41 pm by roland schwarz
originally posted by: wayne matusthis macro should not run on any machine.
it runs fine on my machine.
drc inc.
minneapolis, mn
.designreadycontrols.com
sw2007 sp5.0
core2 quad
3gb ram
xp pro sp2
ati firegl v3600
roland,
it runs fine on my machine with the change. in debug mode without the change swapp is nothing, so it cannot connect to solidworks. it is puzzling why it works on some machines and not on others.
wayne matus
texas engineering systems
a million thanks, wayne.
sw used to use createobject to load the swapp object. i've had some macros that wouldn't work any other way.
still use createobject in vb6, vb.net or excel vba. only use application.sdlworks in solidworks macros.
wayne matus
texas engineering systems
you can use "application.sdlworks" in any program or macro that is running "in-process" with sw threads, such as macros.
the createobject method calls a marshall and searches the rot (running objects table) for the given string ("sldworks.application"), so if it is failing on that machine it means that your solidworks installation is no registering itself correctly for com access, so if i were you i would re-install sw, restart your machine, start sw up at least once and then try the macro again with the getobject function as it should work.
luke,
that explains why my getobject in a vb.net exe programs would not connect to an existing session of solidworks. exitapp would not kill the process either. i ended up having to use brute force to make the program to work. i searched the processes running. if solidworks was, i got the id of the sldworks.exe process and launched a new session of solidworks. at the end of the program i then killed the new sldworks.exe process and left the old one running if there was one.
wayne matus
texas engineering systems
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 03:48 , Processed in 0.034532 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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