title: How to troubleshoot "Object doesn't support this property or method" error for Selection.ShapeRange.Item(1) in vba
body: <p>I am trying to utilise the vba code that I got from <a href="https://www.extendoffice.com/documents/excel/4212-excel-insert-image-from-url.html?comment_id=14382" rel="nofollow noreferrer">here</a>. When I run the macro, selenium webdriver will retrieve the link of the picture and put it near to Z#. However, sometimes after generating the QR image from the website, the generated QR image will have problem to move to the Y# cell and resize.</p>
  <p>The debug will prompt at  <code>Set Pshp = Selection.ShapeRange.Item(1)</code>, showing &quot;Object doesn't support this property or method&quot; error.</p>
  <p>As I will need to generate QR code for several rows of data, I am currently doing row by row.</p>
  <p>As I said, the problem sometimes happens, but in a high frequency (90% of the time). Anyone mind to troubleshoot together? Thanks</p>
  <pre><code>  For i = 6 To Sheet2.Range(&quot;D&quot; &amp; Application.Rows.Count).End(xlUp).Row
              Application.StatusBar = i - 1 &amp; &quot;/&quot; &amp; Sheet2.Range(&quot;D&quot; &amp; Application.Rows.Count).End(xlUp).Row - 1
              bot.FindElementByXPath(&quot;//input[contains(@type,'search')]&quot;).SendKeys (Sheet2.Range(&quot;D&quot; &amp; i))
              bot.Wait 1500
              Report = bot.FindElementByLinkText(&quot;EN&quot;).Attribute(&quot;href&quot;)
              bot.Get Report
              bot.Wait 1500
              QRurl = bot.FindElementByXPath(&quot;//img[contains(@src,'QRimages')]&quot;).Attribute(&quot;src&quot;)
              Sheet2.Range(&quot;Z&quot; &amp; i).Value = QRurl
              Sheet2.Pictures.Insert(QRurl).Select
              Set Pshp = Selection.ShapeRange.Item(1)
              If Pshp Is Nothing Then GoTo lab
                  xcol = Sheet2.Range(&quot;Z&quot; &amp; i).Column - 1
                  Set xRg = Cells(Sheet2.Range(&quot;Z&quot; &amp; i).Row, xcol)
                  With Pshp
                      .LockAspectRatio = msoFalse
                      If .Width &gt; xRg.Width Then .Width = xRg.Width * 9 / 10
                      If .Height &gt; xRg.Height Then .Height = xRg.Height * 9 / 10
                      .Top = xRg.Top + (xRg.Height - .Height) / 2
                      .Left = xRg.Left + (xRg.Width - .Width) / 2
                      .Placement = xlMoveAndSize
                  End With
              
  lab:
      Set Pshp = Nothing
      Range(&quot;Z6&quot;).Select
      
              bot.Get &quot;https://_/_/bulk_upload2_record.php&quot;
              bot.Wait 1000
          Next i
  </code></pre>