<?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 VBA Code Suddenly Not working, No changes, Ways to Fix? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516281#M13913</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a program written in Visual Basic through ArcGIS 9.3 which has worked fine for a few years and now suddenly I get an error every time I try to run it. I have not updated my programs in the recent past and the programming language seems sound to me. My other programs seem to work. Can anyone look at this and help me figure out what might be causing a problem. I get Run-Time error '91' Object variable or With Block variable not set. I have posted the code below, the code I have provided is supposed to go through each layer in my .mxd until it finds one with features selected in it. I get an error on the very last line If pSelSet.Count &amp;gt; 0 Then Exit Do and I can't figure it out.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you checked to see if pLayer.Selectable is true? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if that has an effect on the&amp;nbsp; SelectionSet, but that would be something to check.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Apr 2010 14:30:46 GMT</pubDate>
    <dc:creator>NickClayton</dc:creator>
    <dc:date>2010-04-29T14:30:46Z</dc:date>
    <item>
      <title>VBA Code Suddenly Not working, No changes, Ways to Fix?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516280#M13912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a program written in Visual Basic through ArcGIS 9.3 which has worked fine for a few years and now suddenly I get an error every time I try to run it.&amp;nbsp; I have not updated my programs in the recent past and the programming language seems sound to me.&amp;nbsp; My other programs seem to work.&amp;nbsp; Can anyone look at this and help me figure out what might be causing a problem. I get Run-Time error '91' Object variable or With Block variable not set.&amp;nbsp; I have posted the code below, the code I have provided is supposed to go through each layer in my .mxd until it finds one with features selected in it.&amp;nbsp; I get an error on the very last line If pSelSet.Count &amp;gt; 0 Then Exit Do and I can't figure it out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Public Sub UpdateData()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'On Error GoTo EH:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMxDoc As IMxDocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMap As IMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pActiveView As IActiveView&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pFeatureLayer As IFeatureLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pEnumLayer As IEnumLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pLayer As ILayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pFeature As IFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pMxDoc = Application.Document&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pEnumLayer = pMxDoc.FocusMap.Layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pLayer = pEnumLayer.Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pFeatureSelection As IFeatureSelection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pSelSet As ISelectionSet&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pID As New UID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pID = "esriCore.Editor"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pEditor As IEditor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pWorkspace As IWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pDataset As IDataset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pEnumFeature As IEnumFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim Phasenum As Integer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'========================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do Until pLayer Is Nothing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; If TypeOf pLayer Is IFeatureLayer Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Set pFeatureSelection = pLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Set pSelSet = pFeatureSelection.SelectionSet&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; If pSelSet.Count &amp;gt; 0 Then Exit Do&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; End If&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Apr 2010 14:15:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516280#M13912</guid>
      <dc:creator>JoshuaWallin</dc:creator>
      <dc:date>2010-04-29T14:15:28Z</dc:date>
    </item>
    <item>
      <title>VBA Code Suddenly Not working, No changes, Ways to Fix?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516281#M13913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a program written in Visual Basic through ArcGIS 9.3 which has worked fine for a few years and now suddenly I get an error every time I try to run it. I have not updated my programs in the recent past and the programming language seems sound to me. My other programs seem to work. Can anyone look at this and help me figure out what might be causing a problem. I get Run-Time error '91' Object variable or With Block variable not set. I have posted the code below, the code I have provided is supposed to go through each layer in my .mxd until it finds one with features selected in it. I get an error on the very last line If pSelSet.Count &amp;gt; 0 Then Exit Do and I can't figure it out.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you checked to see if pLayer.Selectable is true? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if that has an effect on the&amp;nbsp; SelectionSet, but that would be something to check.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Apr 2010 14:30:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516281#M13913</guid>
      <dc:creator>NickClayton</dc:creator>
      <dc:date>2010-04-29T14:30:46Z</dc:date>
    </item>
    <item>
      <title>VBA Code Suddenly Not working, No changes, Ways to Fix?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516282#M13914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looks like you missed a few lines on the copy/paste. With the last few lines I added I don't get any errors. Does this happen for you in multiple mxds? Does this also happen if you just use the sub below without any additional code that may have also been in what you pulled this from?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Public Sub UpdateData()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'On Error GoTo EH:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMxDoc As IMxDocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMap As IMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pActiveView As IActiveView&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pFeatureLayer As IFeatureLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pEnumLayer As IEnumLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pLayer As ILayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pFeature As IFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pMxDoc = Application.Document&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pEnumLayer = pMxDoc.FocusMap.Layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pLayer = pEnumLayer.Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pFeatureSelection As IFeatureSelection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pSelSet As ISelectionSet&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pID As New UID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pID = "esriCore.Editor"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pEditor As IEditor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pWorkspace As IWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pDataset As IDataset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pEnumFeature As IEnumFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim Phasenum As Integer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'================================================= =======&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do Until pLayer Is Nothing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If TypeOf pLayer Is IFeatureLayer Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pFeatureSelection = pLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pSelSet = pFeatureSelection.SelectionSet&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If pSelSet.Count &amp;gt; 0 Then Exit Do&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;''All I added &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pLayer = pEnumLayer.Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Sub&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Apr 2010 14:37:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516282#M13914</guid>
      <dc:creator>JohnHauck</dc:creator>
      <dc:date>2010-04-29T14:37:43Z</dc:date>
    </item>
    <item>
      <title>Problem Solved</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516283#M13915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Nice Catch, I had clipped the code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are right, I tried the code in another mxd and it works ok.&amp;nbsp; I am going to try to remake the .mxd and see if that helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Apr 2010 14:46:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516283#M13915</guid>
      <dc:creator>JoshuaWallin</dc:creator>
      <dc:date>2010-04-29T14:46:09Z</dc:date>
    </item>
    <item>
      <title>Resolution to Problem</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516284#M13916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Turns out the reason why my code was erroring out was I had a layer with missing source information because I had renamed it (and hidden it in a group layer). The program worked fine until it needed to layerEnum down to a layer below one of the ones with the missing source.&amp;nbsp; It works at it should now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Apr 2010 16:27:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/vba-code-suddenly-not-working-no-changes-ways-to/m-p/516284#M13916</guid>
      <dc:creator>JoshuaWallin</dc:creator>
      <dc:date>2010-04-29T16:27:21Z</dc:date>
    </item>
  </channel>
</rss>

