zfj8565 发表于 2008-3-25 11:19:00

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

<p>建立的模块名为模块1,过程名为zfj,全部代码如下</p><p>Public Sub zfj()</p><p>Dim AcadApp As AutoCAD.AcadApplication<br/>Set AcadApp = GetObject(, "AutoCAD.Application")<br/>Dim Mydocument As AcadDocument<br/>Set Mydocument = AcadApp.ActiveDocument<br/>Dim Myentity As AcadPolygonMesh<br/>Dim Mysel As AcadSelectionSet<br/>Dim fil_type(0) As Integer<br/>Dim fil_data(0) As Variant<br/>Dim Mycoordinates As Variant<br/>&nbsp;&nbsp;&nbsp; fil_type(0) = 0<br/>&nbsp;&nbsp;&nbsp; fil_data(0) = "PolygonMesh"<br/>On Error Resume Next</p><p>If Not IsNull(Mydocument.SelectionSets.Item("Mysel")) Then<br/>&nbsp;&nbsp;&nbsp; Set Mysel = Mydocument.SelectionSets.Item("Mysel")<br/>&nbsp;&nbsp;&nbsp; Mysel.Delete<br/>End If<br/>Set Mysel = Mydocument.SelectionSets.Add("Mysel")<br/>Dim i, j, k As Integer<br/>Me.hide<br/>Mysel.SelectOnScreen<br/>Me.show<br/>For Each Myentity In Mysel<br/>&nbsp;&nbsp;&nbsp; Mycoordinates = Myentity.Coordinates<br/>Next<br/>Open "D:\zfj\ory.dat" For Append As #1<br/>For i = 0 To (j * 6 - 1) Step 6<br/>Print #1, "gen zone brick size 1,1,1" &amp; " &amp;"<br/>Print #1, "p0" &amp; "(" &amp; Round(Mycoordinates(i), 4) &amp; "," &amp; Round(Mycoordinates(i + 1), 4) &amp; "," &amp; Round(Mycoordinates(i + 2), 4) &amp; ")&amp;"<br/>Print #1, "p1" &amp; "(" &amp; Round(Mycoordinates(i + 3), 4) &amp; "," &amp; Round(Mycoordinates(i + 4), 4) &amp; "," &amp; Round(Mycoordinates(i + 5), 4) &amp; ")&amp;"<br/>Print #1, "p2" &amp; "(" &amp; Round(Mycoordinates(i), 4) &amp; "," &amp; Round(Mycoordinates(i + 1), 4) &amp; "," &amp; Round((Mycoordinates(i + 2) - 1), 4) &amp; ")&amp;"<br/>Print #1, "p3" &amp; "(" &amp; Round(Mycoordinates(i + 6), 4) &amp; "," &amp; Round(Mycoordinates(i + 7), 4) &amp; "," &amp; Round(Mycoordinates(i + 8), 4) &amp; ")&amp;"<br/>Print #1, "p4" &amp; "(" &amp; Round(Mycoordinates(i + 3), 4) &amp; "," &amp; Round(Mycoordinates(i + 4), 4) &amp; "," &amp; Round(Mycoordinates(i + 5) - 1, 4) &amp; ")&amp;"<br/>Print #1, "p5" &amp; "(" &amp; Round(Mycoordinates(i + 6), 4) &amp; "," &amp; Round(Mycoordinates(i + 7), 4) &amp; "," &amp; Round(Mycoordinates(i + 8) - 1, 4) &amp; ")&amp;"<br/>Print #1, "p6" &amp; "(" &amp; Round(Mycoordinates(i + 9), 4) &amp; "," &amp; Round(Mycoordinates(i + 10), 4) &amp; "," &amp; Round(Mycoordinates(i + 11), 4) &amp; ")&amp;"<br/>Print #1, "p7" &amp; "(" &amp; Round(Mycoordinates(i + 9), 4) &amp; "," &amp; Round(Mycoordinates(i + 10), 4) &amp; "," &amp; Round(Mycoordinates(i + 11) - 1, 4) &amp; ")"<br/>Next<br/>Print #1, ";*****************************"<br/>Close #1<br/>Mysel.Delete</p><p>End Sub</p><p>求助:为何一运行就出现“无效使用 Me 关键字”错误呢?请高人指教,在下不胜感激!<br/></p>

雪山飞狐_lzh 发表于 2008-3-25 20:25:00

<p>模块里那里有me?你是在VB里做的?还是VBA?</p>

welcome0511 发表于 2008-3-25 21:16:00

<p>Me.hide<br/>Me.show</p><p>应该指的是窗体USERFORM,在模块中没用</p>

zfj8565 发表于 2008-3-26 11:48:00

是在vba里,应该如何改呢?

zfj8565 发表于 2008-3-26 11:50:00

但是在vb里的话,这段代码不起作用啊

雪山飞狐_lzh 发表于 2008-3-26 13:07:00

<p>如果VB的话,可以这样</p><p>&nbsp;&nbsp;&nbsp; AppActivate ACadApp.Caption<br/>&nbsp;&nbsp;&nbsp; ss.SelectOnScreen<br/>&nbsp;&nbsp;&nbsp; AppActivate Me.Caption<br/></p><p>VBA里,去掉me.***等</p>

xxxtttxxx 发表于 2008-3-26 17:53:00

<p>用版主所说的方法,会不会出现程序被激活,</p><p>但是不在最前台,而是在任务栏里面黄色的一闪一闪呢?</p>
页: [1]
查看完整版本: [求助]在CAD的vba编程中的“me.hide"问题