Renaming *-E Layer Names to Exst

Renaming *-E Layer Names to Exst

Anonymous
Not applicable
583 Views
10 Replies
Message 1 of 11

Renaming *-E Layer Names to Exst

Anonymous
Not applicable
I am trying to rename a group of layers that end with -E to Exst But thing
is I want to get rid of the -E and everytime I run my macro it just adds
Exst to the end of my layer names... does any one know how to subtrat the
last 2 characters and swap the name to Exst?


Public Sub RenameLayers()
Dim lays As AcadLayers
Dim layerObj As AcadLayer
Dim lay As AcadLayer
Dim strLayerName As String

On Error Resume Next

Set lays = ThisDrawing.Layers
For Each lay In lays
Set layerObj = ThisDrawing.Layers(lay.Name)
strLayerName = layerObj.Name
layerObj.Name = strLayerName & "Exst"
Next lay
End Sub
0 Likes
584 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
There could be various ways of doing what you want, but I would do like this:

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", "-Exst")
Next lay
0 Likes
Message 3 of 11

Anonymous
Not applicable
"Rick Holguin" wrote in message
news:5866280@discussion.autodesk.com...
I am trying to rename a group of layers that end with -E to Exst But thing
is I want to get rid of the -E and everytime I run my macro it just adds
Exst to the end of my layer names... does any one know how to subtrat the
last 2 characters and swap the name to Exst?


Public Sub RenameLayers()
Dim lays As AcadLayers
Dim layerObj As AcadLayer
Dim lay As AcadLayer
Dim strLayerName As String

On Error Resume Next

Set lays = ThisDrawing.Layers
For Each lay In lays
Set layerObj = ThisDrawing.Layers(lay.Name)
strLayerName = layerObj.Name


layerObj.Name = Replace( strLayerName , "-E", "Exst")

Next lay
End Sub

hth
mark
0 Likes
Message 4 of 11

Anonymous
Not applicable
Ok let me try it.. thanks for your help!
wrote in message news:5866291@discussion.autodesk.com...
There could be various ways of doing what you want, but I would do like
this:

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", "-Exst")
Next lay
0 Likes
Message 5 of 11

Anonymous
Not applicable
It works perfect..... but If I want to have a dialog box pop up and have an
input box then all I have to do is create a string for the layer prefix "-E"
right?
wrote in message news:5866291@discussion.autodesk.com...
There could be various ways of doing what you want, but I would do like
this:

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", "-Exst")
Next lay
0 Likes
Message 6 of 11

Anonymous
Not applicable
I am not a big fan of dialog boxes for user inputs, unless really necessary. I prefer using the command prompt. Here is how I would do it.

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String

str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix: ")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub
0 Likes
Message 7 of 11

Anonymous
Not applicable
How about this 2 command promts....

Check it out!!! thanks John!! john you know your stuff... send me your
direct email adress.... if not its ok thanks for your expertise!! you da
man!

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String
Dim str2 As String
str2 = ThisDrawing.Utility.GetString(False, "Enter prefix layer name To Be
Changed: <-E> ")
str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, str2, IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub

wrote in message news:5867190@discussion.autodesk.com...
I am not a big fan of dialog boxes for user inputs, unless really necessary.
I prefer using the command prompt. Here is how I would do it.

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String

str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub
0 Likes
Message 8 of 11

Anonymous
Not applicable
fwiw, from your posts looks like you're actually doing suffixes not prefixes

mark

"Rick Holguin" wrote in message
news:5867442@discussion.autodesk.com...
How about this 2 command promts....

Check it out!!! thanks John!! john you know your stuff... send me your
direct email adress.... if not its ok thanks for your expertise!! you da
man!

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String
Dim str2 As String
str2 = ThisDrawing.Utility.GetString(False, "Enter prefix layer name To Be
Changed: <-E> ")
str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, str2, IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub

wrote in message news:5867190@discussion.autodesk.com...
I am not a big fan of dialog boxes for user inputs, unless really necessary.
I prefer using the command prompt. Here is how I would do it.

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String

str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub
0 Likes
Message 9 of 11

Anonymous
Not applicable
Yes its suffix... hey do I get it to do Prefix.... you know in the middle of
a layer name??
"MP" wrote in message
news:5867515@discussion.autodesk.com...
fwiw, from your posts looks like you're actually doing suffixes not prefixes

mark

"Rick Holguin" wrote in message
news:5867442@discussion.autodesk.com...
How about this 2 command promts....

Check it out!!! thanks John!! john you know your stuff... send me your
direct email adress.... if not its ok thanks for your expertise!! you da
man!

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String
Dim str2 As String
str2 = ThisDrawing.Utility.GetString(False, "Enter prefix layer name To Be
Changed: <-E> ")
str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, str2, IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub

wrote in message news:5867190@discussion.autodesk.com...
I am not a big fan of dialog boxes for user inputs, unless really necessary.
I prefer using the command prompt. Here is how I would do it.

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String

str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub
0 Likes
Message 10 of 11

Anonymous
Not applicable
Look at Instr and Mid$

"Rick Holguin" wrote in message
news:5867609@discussion.autodesk.com...
Yes its suffix... hey do I get it to do Prefix.... you know in the middle of
a layer name??
"MP" wrote in message
news:5867515@discussion.autodesk.com...
fwiw, from your posts looks like you're actually doing suffixes not prefixes

mark

"Rick Holguin" wrote in message
news:5867442@discussion.autodesk.com...
How about this 2 command promts....

Check it out!!! thanks John!! john you know your stuff... send me your
direct email adress.... if not its ok thanks for your expertise!! you da
man!

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String
Dim str2 As String
str2 = ThisDrawing.Utility.GetString(False, "Enter prefix layer name To Be
Changed: <-E> ")
str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, str2, IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub

wrote in message news:5867190@discussion.autodesk.com...
I am not a big fan of dialog boxes for user inputs, unless really necessary.
I prefer using the command prompt. Here is how I would do it.

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String

str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub
0 Likes
Message 11 of 11

Anonymous
Not applicable
Thanks for your help!
"MP" wrote in message
news:5867822@discussion.autodesk.com...
Look at Instr and Mid$

"Rick Holguin" wrote in message
news:5867609@discussion.autodesk.com...
Yes its suffix... hey do I get it to do Prefix.... you know in the middle of
a layer name??
"MP" wrote in message
news:5867515@discussion.autodesk.com...
fwiw, from your posts looks like you're actually doing suffixes not prefixes

mark

"Rick Holguin" wrote in message
news:5867442@discussion.autodesk.com...
How about this 2 command promts....

Check it out!!! thanks John!! john you know your stuff... send me your
direct email adress.... if not its ok thanks for your expertise!! you da
man!

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String
Dim str2 As String
str2 = ThisDrawing.Utility.GetString(False, "Enter prefix layer name To Be
Changed: <-E> ")
str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, str2, IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub

wrote in message news:5867190@discussion.autodesk.com...
I am not a big fan of dialog boxes for user inputs, unless really necessary.
I prefer using the command prompt. Here is how I would do it.

Public Sub LayerName_Change()
Dim lay As AcadLayer
Dim str As String

str = ThisDrawing.Utility.GetString(False, "Enter layer name prefix:
")

For Each lay In ThisDrawing.Layers
lay.Name = Replace(lay.Name, "-E", IIf(Len(str) = 0, "-Exst", str))
Next lay

End Sub
0 Likes