Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .Paste not working everytime

I have a macro that is going to intranet site through internet
explorer. It is to pull up a page, copy all the whole page, and paste
the contents into an excel file. I have everything working up to the
point of pasting the data. My first problem is the ActiveSheet.paste
works for maybe 10 rounds, but then it errors out with run time error
'1004' Paste Method of worksheet class failed. So, i changed to code to
use pastespecial, but i then get run time error '1004' PasteSpecial
method of range class failed, which doesn't run at all. My second
problem is that when the code decides to run without any errors, what
is getting copied is not what is getting pasted. Its actually pasting
one screen behind.

CODE
Sub FIT_File_Update_Wing_Info()

Dim IeApp As InternetExplorer
Dim sUrl As String
Dim fso As New FileSystemObject
Dim fls As Files
Dim unitno As String
Dim fname As String

'Get the Fitness Work Folder contents
Set fls = fso.GetFolder("C:\Folder").Files

'Get Internet Explorer Object to open window
Set IeApp = New InternetExplorer

'Loop through the filenames in thefolder
'and get data from Portal
For Each f In fls
Debug.Print f.Name

numint = Mid(f.Name, 7, 3)
fname = f.Name
sUrl = "http://yahoo.com" 'can't put real url


Debug.Print "UnitNo: " & numint

Debug.Print "Fname: " & fname



'Display the Internet Explorer window
IeApp.Visible = True

'Open up report
IeApp.Navigate sUrl
Do
Loop Until IeApp.ReadyState = READYSTATE_COMPLETE

'Needed pause before copying data
Application.Wait (Now + TimeValue("0:00:10"))

'Select and copy report
SendKeys "%ea"
SendKeys "%ec"

'Debug.Print "Open Fname: " & fname & vbCrLf & vbCrLf

'Open the xls file and paste the portal data
Workbooks.Open Filename:="C:\Folder\" & fname
Windows(fname).Activate
Cells.Clear
Cells.Select

Range("A1").Select

'The code lines around the paste statement, supress a message box
that
'kept coming up that i needed to default to OK each time in order
for the
'paste action to go through without user interface

Application.DisplayAlerts = True
ActiveSheet.Paste '********keeps erroring
out here****************
Application.DisplayAlerts = False

'Clear Clipboard
Application.CutCopyMode = False

'Close & save the xls file
ActiveWindow.Close (True)

'Empty Variables
numint = ""
fname = ""


Next

IeApp.Quit

'Clear Objects
Set fso = Nothing
Set fls = Nothing
Set IeApp = Nothing


End Sub

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
paste link not working Sam Excel Discussion (Misc queries) 1 February 18th 10 08:06 PM
Paste and Paste Special No Longer Working - Excel 2003 SheriJ Excel Discussion (Misc queries) 2 January 15th 09 09:23 PM
copy/paste not working chicago1 Excel Worksheet Functions 3 March 5th 08 05:20 PM
ACTIVESHEET.PASTE not working. Marco Excel Programming 3 July 27th 05 02:11 AM
copy paste is not working Becky1810 Excel Discussion (Misc queries) 1 July 16th 05 02:12 PM


All times are GMT +1. The time now is 09:51 PM.

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"