Sub MyTask()

Dim ie As Object
Dim c As Long

Set objWSS = CreateObject("WScript.Shell")
Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = True
.navigate "http://MyPage"

Do While .ReadyState <> 4: DoEvents: Loop

'** Above goes to my website

With .Document.Forms(0)
.UserName.Value = "MyUsername"
.Password.Value = "MyPassword"
.Action.Click
End With

'** Above logs in to my website

While c <= 9999999
c = c + 1
Wend
c = 1

'** Above waits till username and password is authenticated

Do While .ReadyState <> 4: DoEvents: Loop

With ie
.navigate "http://MyPage/MyAspPage"

Do While .ReadyState <> 4: DoEvents: Loop

'** Above pulls up the page that I want in the same IE window I am
doing this because I have to be logged in.

End With

ie.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT, Null,
Null
ie.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT, Null, Null

Range("A1").Select
ActiveSheet.Paste
Range("A1").Select

'** Above puts the data in clipboard (SELECTALL) and paste it in A1

End With

ie.Quit
Set ie = Nothing

End Sub

I get an error:
Run-time error '1004':
Paste method of Worksheet class failed

Note: For the above code to work, CHECK Microsoft Internet Controls
from Tools->References in the VBA window

Sometimes it works and sometimes it gives me error. I do not understand
why is it acting so funny