<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic rename layer's name in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307801#M8006</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone share vba code or example to rename the layer's name base on one of record's value?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for anyone who help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regards'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yosie&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 13 Nov 2010 03:22:43 GMT</pubDate>
    <dc:creator>yosiwidiyanto</dc:creator>
    <dc:date>2010-11-13T03:22:43Z</dc:date>
    <item>
      <title>rename layer's name</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307801#M8006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone share vba code or example to rename the layer's name base on one of record's value?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for anyone who help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regards'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yosie&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Nov 2010 03:22:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307801#M8006</guid>
      <dc:creator>yosiwidiyanto</dc:creator>
      <dc:date>2010-11-13T03:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: rename layer's name</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307802#M8007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dim pMxdoc as imxdocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set pMxdoc = thisdocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'Get the feature (pFeature)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'Get the layer (pLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pLayer.Name = pFeature.Value(Idx)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pMxdoc.UpdateContents&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am giving you the abbreviate untested version but something like this should work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Nov 2010 21:21:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307802#M8007</guid>
      <dc:creator>SteveFang</dc:creator>
      <dc:date>2010-11-15T21:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: rename layer's name</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307803#M8008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I use userform to choose field value, I want the layer�??s name is the same as the selected list in the combo box. I get error at strLayer = pFeature.Value(pFeature.fields.FindField("Tanah"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and the code is: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Private Sub cmdRename_Click()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMxDoc As IMxDocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pMxDoc = ThisDocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMap As IMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pMap = pMxDoc.FocusMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pLayer As IFeatureLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pFeature As IFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim strLayer As String&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set strLayer = pFeature.Value(pFeature.fields.FindField("Tanah"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pLayer.Name = pFeature.Value(strLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pMxDoc.UpdateContent&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What should I do now to make this code run well? Thanks Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Nov 2010 10:11:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307803#M8008</guid>
      <dc:creator>yosiwidiyanto</dc:creator>
      <dc:date>2010-11-20T10:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: rename layer's name</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307804#M8009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well based on a quick look, pFeature is nothing.&amp;nbsp; Declaring a variable without setting it to anything, will result in an 'empty' or nothing variable.&amp;nbsp; You cannot access any of the methods and properties on a nothing variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also you will get an error on this line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pLayer.Name = pFeature.Value(strLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Because pLayer is nothing.&amp;nbsp; You need to set pLayer to something.&amp;nbsp; For example the first layer of the map: pLayer = pMxDoc.FocusMap.Layer(0).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course you are probably looking for a specific layer so you may need to loop through the layers in the map or something.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you have the layer you are interested in, you can Query Interface to get the IFeatureLayer (if it applies.)&amp;nbsp; IFeatureLayer has the FeatureClass property of type IFeatureClass.&amp;nbsp; The IFeatureClass has a search method that returns a featurecursor.&amp;nbsp; IFeatureCursor.NextFeature returns a feature of type IFeature.&amp;nbsp; That should give you a populated feature that has values in it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;another thing you should not use "Set" for a string.&amp;nbsp; In VBA "Set" is only used for object (quick rule of thumb if I can write the value down no set, if I can't, use set, works 99% of the time.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Aside from that, field might not be found (findfield returns -1) or the value in that field for that feature could be null.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Nov 2010 17:10:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307804#M8009</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2010-11-22T17:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: rename layer's name</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307805#M8010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot. My code runs well now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Nov 2010 11:46:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/rename-layer-s-name/m-p/307805#M8010</guid>
      <dc:creator>yosiwidiyanto</dc:creator>
      <dc:date>2010-11-23T11:46:33Z</dc:date>
    </item>
  </channel>
</rss>

