本帖最后由 Flyingdancing 于 2012-11-12 08:55 编辑
- 添加layer用layers的add
- 判断layer可以用layer的名字name
- 或者layers.item(i)——就是layer;的名字name
- Set oldLayer = ThisDrawing.ActiveLayer
- ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Dim")
改成- On Error Resume Next
- Set oldlayer = ThisDrawing.Layers.Item("Dim")
- If Err Then
- Err.Clear
- Set oldlayer = ThisDrawing.Layers.Add("Dim")
- End If
- ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Dim")
或者- Dim Mark As Integer
- Mark = 0
- For i = 0 To ThisDrawing.Layers.Count
- If ThisDrawing.Layers(i).Name = "Dim" Then
- Mark = 1
- Exit For
- End If
- Next
- If Mark = 1 Then
- Set oldlayer = ThisDrawing.Layers.Add("dim")
- Else
- Set oldlayer = ThisDrawing.Layers.Item("Dim")
- End If
- ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Dim")
|