Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste method of worksheet class failed
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste method of worksheet class failed
It is possible that the failure results from the clipboard being empty. Can
you check the clipboard staus before attempting the paste? -- Gary''s Student "Maxi" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste method of worksheet class failed
That is exactly what I was thinking of
But sometimes it works which proves that data is copied to the clipboard. Therefore the only possibility left out is sometimes the data is copied to the clipboard and sometimes not becuase of which ActiveSheet.Paste does not work. I am not sure how to tackle this issue. How do you check the status of the clipboard? What would be the syntax? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error Paste Method of Worksheet class failed | Excel Programming | |||
paste method of worksheet class failed | Excel Programming | |||
runtime error 1004 paste method of worksheet class failed | Excel Programming | |||
Run Time error 1004 Paste Method of Worksheet Class Failed | Excel Programming | |||
Paste method of worksheet class failed error | Excel Programming |