title: Excel crashing when using PasteSpecial
body: <p>I am using the following code to read some data from a webpage and then pasting is into a sheet. I do this process twice (i.e. for 2 webpages) in the same sub. However, when using pastespecial for the second time, Excel crashes and I have no idea why this happens.</p>
  
  <pre><code>Sub main()
  
      Application.ScreenUpdating = False
  
      Dim ie As InternetExplorer
      Dim doc As HTMLDocument
      Dim inputEl As HTMLInputElement
  
      Set ie = New InternetExplorer
  
      'open website
      ie.navigate "http://...website.../page1.html"
      ie.Visible = False
      Sleep 5000
      While ie.Busy
          DoEvents
      Wend
  
  ''now copying source code to excel
  Set doc = ie.document
  CopyText doc.body.innerHTML
  
  Sheet3.Activate
  Sheet3.Cells.Clear
  Sheet3.DrawingObjects.Delete
  Range("A1").Select
  Range("A1").PasteSpecial xlPasteAll
  
  'opening second page
  ie.navigate "http://...website.../page2.html"
  Sleep 2000
  While ie.Busy
      DoEvents
  Wend
  Set doc = ie.document
  
  Sheet8.Activate
  Sheet8.DrawingObjects.Delete
  CopyText doc.body.innerHTML
  
  Range("A1").Select
  '''''Excel crashes after this point, specifically on the next line
  Sheet8.Range("A1").PasteSpecial xlPasteAll
  
  End Sub
  </code></pre>
  
  <p>For reference, I used a function CopyText (borrowed from internet) which is defined below:</p>
  
  <pre><code>Public Sub CopyText(Text As String)
      Dim MSForms_DataObject As Object
      Set MSForms_DataObject = CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
      MSForms_DataObject.SetText Text
      MSForms_DataObject.PutInClipboard
      Set MSForms_DataObject = Nothing
  End Sub
  </code></pre>
  
  <p>I tried using this as well but didn't help - <a href="https://stackoverflow.com/questions/19218623/pastespecial-crashing-when-pasting-excel-data">pastespecial Crashing when pasting excel data</a></p>