明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1436|回复: 6

[求助]在CAD的vba编程中的“me.hide"问题

[复制链接]
发表于 2008-3-25 11:19:00 | 显示全部楼层 |阅读模式

建立的模块名为模块1,过程名为zfj,全部代码如下

Public Sub zfj()

Dim AcadApp As AutoCAD.AcadApplication
Set AcadApp = GetObject(, "AutoCAD.Application")
Dim Mydocument As AcadDocument
Set Mydocument = AcadApp.ActiveDocument
Dim Myentity As AcadPolygonMesh
Dim Mysel As AcadSelectionSet
Dim fil_type(0) As Integer
Dim fil_data(0) As Variant
Dim Mycoordinates As Variant
    fil_type(0) = 0
    fil_data(0) = "PolygonMesh"
On Error Resume Next

If Not IsNull(Mydocument.SelectionSets.Item("Mysel")) Then
    Set Mysel = Mydocument.SelectionSets.Item("Mysel")
    Mysel.Delete
End If
Set Mysel = Mydocument.SelectionSets.Add("Mysel")
Dim i, j, k As Integer
Me.hide
Mysel.SelectOnScreen
Me.show
For Each Myentity In Mysel
    Mycoordinates = Myentity.Coordinates
Next
Open "D:\zfj\ory.dat" For Append As #1
For i = 0 To (j * 6 - 1) Step 6
Print #1, "gen zone brick size 1,1,1" & " &"
Print #1, "p0" & "(" & Round(Mycoordinates(i), 4) & "," & Round(Mycoordinates(i + 1), 4) & "," & Round(Mycoordinates(i + 2), 4) & ")&"
Print #1, "p1" & "(" & Round(Mycoordinates(i + 3), 4) & "," & Round(Mycoordinates(i + 4), 4) & "," & Round(Mycoordinates(i + 5), 4) & ")&"
Print #1, "p2" & "(" & Round(Mycoordinates(i), 4) & "," & Round(Mycoordinates(i + 1), 4) & "," & Round((Mycoordinates(i + 2) - 1), 4) & ")&"
Print #1, "p3" & "(" & Round(Mycoordinates(i + 6), 4) & "," & Round(Mycoordinates(i + 7), 4) & "," & Round(Mycoordinates(i + 8), 4) & ")&"
Print #1, "p4" & "(" & Round(Mycoordinates(i + 3), 4) & "," & Round(Mycoordinates(i + 4), 4) & "," & Round(Mycoordinates(i + 5) - 1, 4) & ")&"
Print #1, "p5" & "(" & Round(Mycoordinates(i + 6), 4) & "," & Round(Mycoordinates(i + 7), 4) & "," & Round(Mycoordinates(i + 8) - 1, 4) & ")&"
Print #1, "p6" & "(" & Round(Mycoordinates(i + 9), 4) & "," & Round(Mycoordinates(i + 10), 4) & "," & Round(Mycoordinates(i + 11), 4) & ")&"
Print #1, "p7" & "(" & Round(Mycoordinates(i + 9), 4) & "," & Round(Mycoordinates(i + 10), 4) & "," & Round(Mycoordinates(i + 11) - 1, 4) & ")"
Next
Print #1, ";*****************************"
Close #1
Mysel.Delete

End Sub

求助:为何一运行就出现“无效使用 Me 关键字”错误呢?请高人指教,在下不胜感激!

发表于 2008-3-25 20:25:00 | 显示全部楼层

模块里那里有me?你是在VB里做的?还是VBA?

发表于 2008-3-25 21:16:00 | 显示全部楼层

Me.hide
Me.show

应该指的是窗体USERFORM,在模块中没用

 楼主| 发表于 2008-3-26 11:48:00 | 显示全部楼层
是在vba里,应该如何改呢?
 楼主| 发表于 2008-3-26 11:50:00 | 显示全部楼层
但是在vb里的话,这段代码不起作用啊
发表于 2008-3-26 13:07:00 | 显示全部楼层

如果VB的话,可以这样

    AppActivate ACadApp.Caption
    ss.SelectOnScreen
    AppActivate Me.Caption

VBA里,去掉me.***等

发表于 2008-3-26 17:53:00 | 显示全部楼层

用版主所说的方法,会不会出现程序被激活,

但是不在最前台,而是在任务栏里面黄色的一闪一闪呢?

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 10:51 , Processed in 0.185525 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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