Aliases.Remove method

AutoCAD Map 3D ActiveX

Aliases.Remove method

Removes a drive alias.

Remove(Index As Variant) As Boolean

Returns True on success.

Index

Index, starting at 0, or name of an alias in the collection.

Each project comes with a default alias called C:=C. Removing this alias is not recommended and causes an error when you run the following example. This example creates an alias called SHAREDDRIVE, lists all defined alises, and then removes SHAREDDRIVE.

Dim als As Alias

Dim amap As AcadMap

Dim cAls As Integer, i As Integer

Dim strOutput As String

Dim strAlsName As String

Dim boolAlsOK As Boolean

 

boolAlsOK = True

strAlsName = "SHARED2DRIVE"

Set amap = ThisDrawing.Application. _

GetInterfaceObject("AutoCADMap.Application") 

cAls = amap.aliases.Count

'Code to check uniqueness of alias name goes here. See Aliases.Add

Set als = amap.aliases.Add(strAlsName, "C:\\Temp")

cAls = amap.aliases.Count

For i = 0 To cAls - 1

Set als = amap.aliases.Item(i) 

strOutput = strOutput & als.Name & "=" & als.Directory & Chr(13) 

Next i

MsgBox strOutput

cAls = amap.aliases.Count

For i = 0 To cAls - 1

Set als = amap.aliases.Item(i) 

If als.Name = strAlsName Then 

amap.aliases.Remove (als.Name) 

Debug.Print "Removed " & strAlsName 

End If 

Next i