Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
.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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
paste link not working | Excel Discussion (Misc queries) | |||
Paste and Paste Special No Longer Working - Excel 2003 | Excel Discussion (Misc queries) | |||
copy/paste not working | Excel Worksheet Functions | |||
ACTIVESHEET.PASTE not working. | Excel Programming | |||
copy paste is not working | Excel Discussion (Misc queries) |