下面是我在Excel中使用的vba例程:
- Sub DbxEx()
- Dim oDbx As AxDbDocument 'Add Reference to ObjectDbx Library
- Dim fPath, fName As String
- Dim oLay As AcadLayer
- fPath = "C:\Documents and Settings\user\Desktop\New Folder" 'Change Directory to Suit
- fName = Dir(fPath & "*.dwg", vbNormal)
- Do Until fName = ""
- Set oDbx = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument.17") 'Change to match Your Version
- oDbx.Open (fPath & fName)
- For Each oLay In oDbx.Layers
- If oLay.Name = "HOUSE" Or oLay.Name = "SHED" Or oLay.Name = "GARAGE" Then
- oLay.color = acWhite
- End If
- Next oLay
- oDbx.SaveAs (fPath & fName)
- Set oDbx = Nothing
- fName = Dir()
- Loop
- End Sub
ska公司 |