Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error Paste Method of Worksheet class failed ca1358 Excel Programming 2 January 4th 06 03:08 PM
paste method of worksheet class failed Dwaine Horton[_3_] Excel Programming 7 August 11th 05 07:50 PM
runtime error 1004 paste method of worksheet class failed wilsoj Excel Programming 12 August 10th 05 08:20 PM
Run Time error 1004 Paste Method of Worksheet Class Failed Ken Nunn Excel Programming 3 June 29th 04 03:23 PM
Paste method of worksheet class failed error Todd Huttenstine[_2_] Excel Programming 1 December 16th 03 10:08 AM


All times are GMT +1. The time now is 05:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"