关于以前写的VBA在新版本64位Inventor中无法使用的问题
2010-05-21 16:04
579 查看
问题:以前使用的VBA程序,使用了诸如ThisDocument、Me这样的对象,在新版的Inventor 64位里面,无法使用了。(现在需要使用ThisDocument.InventorDocument这样的表述方法),并且由于使用了Autoopen这样的自动执行的函数,导致打开一个Inventor部件的时候,弹出大量的错误对话框。能否将Inventor里面的VBA功能禁用,或者禁用AutoOpen函数?能否批量的将零件文件中的VBA程序代码删除或改写,这种操作是可以脱离Inventor进程进行,还是必须在Inventor中进行?
解决方法:
一、按住shift健就可以禁用Auto宏命令,Inventor API帮助文档里有说明:
"Autodesk Inventor runs automatic macros automatically whenever the associated events occur. If the user presses the Shift key when the event occurs, the automatic macro
will not run. For example, if the user presses the Shift key while opening a document that contains an AutoOpen macro, the macro will not run."
二、要删除或者修改VBA程序,有两种方法:
可以编写VBA项目(.ivb文件)或者一个简单的宏命令来删除文件中的VBA程序(等用户打开了文件后执行该命令)。例子如下:
注:需要增加Microsoft Visual Basic for Applications Extensibility library (工具 -> 参考...)。 CodeModule还有一个ReplaceLine函数可以修改VBA代码。
你也可以做个插件实现上述代码,再做个菜单方便界面调用。插件的一个好处是它可以有安装程序,所以不用配置/修改用户机器上的默认的.ivb文件(应用程序项目),也不用你手动的去加载你的VBA项目。
以上两种方法都离不开Inventor进程。
三,这种方法可以脱离Inventor,请看我的另外一篇文章:免费的删除文档中的VBA程序的工具及源码
解决方法:
一、按住shift健就可以禁用Auto宏命令,Inventor API帮助文档里有说明:
"Autodesk Inventor runs automatic macros automatically whenever the associated events occur. If the user presses the Shift key when the event occurs, the automatic macro
will not run. For example, if the user presses the Shift key while opening a document that contains an AutoOpen macro, the macro will not run."
二、要删除或者修改VBA程序,有两种方法:
可以编写VBA项目(.ivb文件)或者一个简单的宏命令来删除文件中的VBA程序(等用户打开了文件后执行该命令)。例子如下:
'You need to set a reference to the Microsoft Visual Basic for Applications 'Extensibility library, Tools > References Sub test() Dim l_mod As InventorVBAComponent ' VBComponent Dim l_project As InventorVBAProject For Each l_project In ThisApplication.VBAProjects If l_project.ProjectType = kDocumentVBAProject Then For Each l_mod In l_project.InventorVBAComponents 'ThisDocument module can't be deleted, so if Thisdocument, delete code of lines If l_mod.Name <> "ThisDocument" Then l_mod.VBComponent.Activate l_project.VBProject.VBComponents.Remove l_mod Else l_mod.VBComponent.CodeModule.DeleteLines 1, l_mod.VBComponent.CodeModule.CountOfLines End If Next End If Next End Sub
注:需要增加Microsoft Visual Basic for Applications Extensibility library (工具 -> 参考...)。 CodeModule还有一个ReplaceLine函数可以修改VBA代码。
你也可以做个插件实现上述代码,再做个菜单方便界面调用。插件的一个好处是它可以有安装程序,所以不用配置/修改用户机器上的默认的.ivb文件(应用程序项目),也不用你手动的去加载你的VBA项目。
以上两种方法都离不开Inventor进程。
三,这种方法可以脱离Inventor,请看我的另外一篇文章:免费的删除文档中的VBA程序的工具及源码
相关文章推荐
- 关于在TEE环境下,无法使用htobe64函数的问题
- 关于Ubuntu发行版升级造成 grub 无法使用的问题
- 关于使用JFinal构建maven项目时,使用jetty启动项目,无法渲染jsp页面的问题
- 关于CIPADDRESSCTRL在win32SDK中无法使用的问题
- 关于IE6中无法使用margin:0 auto居中的问题终极解决方案
- 关于centos更新后virtualbox无法使用的问题
- 关于js文件引入无法使用的问题
- 关于使用javah生成头文件时无法访问class文件的问题
- (应用程序无法正常启动0xc0000142) 关于win10周年版更新后无法正常使用vc6.0问题的解决方法
- 关于使用LayoutParams清除设置以及DateFormat无法正确转换格式化日期的问题
- 关于使用Silverlight Toolkit 3 中的主题后DataGrid无法呈现数据的问题
- 64位操作系统使用PLSQL Developer时,“无法解析指定的连接标识符”问题的解决办法
- 关于使用Silverlight通过IP地址访问本地ArcGIS Server发布的Rest服务无法出图的问题
- 关于使用netbeans无法使用编码utf-8安全地打开文件的问题
- 关于在使用Exchange2003系统时无法向sina,yahoo,hotmail等邮箱发送邮件问题的解决方法
- 关于Andriod Studio 2.3 无法使用自定义字体的问题
- 关于使用图片轮播插件无法实现效果的问题
- 关于在Visual Studio中无法使用中文输入法的问题
- ubuntu12.04+virtualbox+winxp的关于摄像头无法使用,声音出不来的问题
- 关于cookie在ie8中无法使用在FF下可用的问题