simatyga 发表于 2009-3-12 09:44:00

[求助]禁止用户编辑某图层

<font face="宋体" size="2">我想禁止用户修改某个图层,把该图层锁定,然后编程不让用户打开锁定,可是下面的程序运行的时候会出现“对象已打开”的错误。<br/><br/>Private Sub AcadDocument_ObjectModified(ByVal Object As Object)<br/><br/>Dim subBool As Boolean<br/>Dim subName_Obj As String<br/>On Error Resume Next<br/>subName_Obj = Object.ObjectName<br/>If Err &lt;&gt; 0 Then<br/>Err.Clear<br/>ElseIf subName_Obj = "AcDbLayerTableRecord" Then<br/>If Object.Name = "锁定图层" Then<br/>loclayer<br/>End If<br/>End If<br/>End Sub<br/><br/>Public Sub locklayer()<br/>On Error Resume Next<br/><br/>Dim layer As AcadLayer<br/>Set layer = thisdrawing.Layers("锁定图层")<br/>layer.TrueColor = c251<br/>layer.LayerOn = True<br/>layer.Lock = True<br/>layer.Freeze = False<br/><br/>If Err &lt;&gt; 0 Then<br/>MsgBox Err.Description<br/>End If<br/>End Sub</font>
页: [1]
查看完整版本: [求助]禁止用户编辑某图层