明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 835|回复: 3

请教大侠:Excelvba 打开CAD文件后没执行命令

[复制链接]
发表于 2015-5-25 16:13:15 | 显示全部楼层 |阅读模式
请教大侠:我是用excelvba打开一个CAD文件,然后删除CAD里面的某个块。但往往是删除这个命令没有执行,是不是文件没有完全打开,就已经执行了删除命令呢,导致没有执行成功?
那么应该怎样让删除命令顺利执行呢,我刚学习这个,在论坛也找不到相关资料,麻烦各位不吝赐教。

Call open……
Call DeleteBlock("A1")   '此命令没执行
发表于 2015-5-25 22:03:34 | 显示全部楼层
  1. Public WithEvents ACADApp As AcadApplication    ' Use with Application Event Examples
  2. Sub Example_AcadApplication_Events()
  3.     ' This example intializes the public variable (ACADApp) which will be used
  4.     ' to intercept AcadApplication Events
  5.     '
  6.     ' The VBA WithEvents statement makes it possible to intercept an generic object
  7.     ' with the events associated with that object.
  8.     '
  9.     ' Before you will be able to trigger any of the AcadApplication events,
  10.     ' you will first need to run this procedure.
  11.    
  12.     ' We could get the application from the ThisDocument object, but that would
  13.     ' require having a drawing open, so we grab it from the system.
  14.     Set ACADApp = GetObject(, "AutoCAD.Application.19")
  15. End Sub

  16. Private Sub ACADApp_EndOpen(ByVal FileName As String)
  17.     ' This example intercepts an Application EndOpen event.
  18.     '
  19.     ' This event is triggered when AutoCAD finishes opening a drawing.
  20.     '
  21.     ' To trigger this example event:
  22.     '     1) Make sure to run the example that initializes
  23.     '     the public variable (named ACADApp) linked to this event.
  24.     '
  25.     '     2) Use AutoCAD to open an existing drawing and wait until the
  26.     '     operation finishes

  27.     ' Use the "FileName" variable to determine which drawing file is being opened
  28.     MsgBox "A drawing was just loaded from: " & FileName
  29. End Sub
 楼主| 发表于 2015-5-26 10:33:37 | 显示全部楼层
zzyong00 发表于 2015-5-25 22:03

非常感谢大侠的回复,不过我刚接触这个,还是搞不明白应该怎么处理,能不能结合我的例子详细说明呢,谢谢!
是不是这样的呢?似乎通不过[em0]

Call open……
Call ACADApp_EndOpen(filename)
Call DeleteBlock("A1")   

点评

貌你不明白什么是事件!以及事件编程的相关的东西,先学学vb再说  发表于 2015-5-26 22:21
 楼主| 发表于 2015-5-28 18:53:23 | 显示全部楼层
OK,已经搞定,看了些教程拿来急用先了,哈哈,谢谢 zzyong00的指点
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 12:29 , Processed in 0.171120 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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