Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Copy data from IE to Excel

The code given below opens Internet Explorer, goes to my internet web
page, uses the userid and password that I have suppied, logs in, then
again goes to a specific page and pulls it up. Then it copies the
entire data on that page (turn on Microsoft Internet Controls from
Tools-References) and paste it in A1 of Sheet1.

The above code works fine if I go step by step using the F8 key in the
VBA macro window but when I run the code entirely then it goes so fast
that it does not run the <<Do While .busy: DoEvents: Loop and <<Do
While .ReadyState < 4: DoEvents: Loop lines and it does not login to
my asp page hence cannot pull the specific page (second url)

Any ideas???

TURN ON MICROSOFT INTERNET CONTROLS FROM TOOLS-REFERENCES
================================================== ========

Public Declare Function ShowWindow& Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Integer)

Sub LoginWebReports()

Dim ie As Object

On Error GoTo 1

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

With ie
.Visible = True
.navigate "http://www.MyIntranetASPPage.com"
Do While .busy: DoEvents: Loop
Do While .ReadyState < 4: DoEvents: Loop
With .Document.Forms(0)
.UserName.Value = "MyUsername"
.Password.Value = "MyPassword"
.Action.Click
End With

' <<I am navigating below once again to a different URL only because, I
have to login to the above page first"

With ie
.Visible = True
.navigate
"http://www.MyIntranetASPPage.com/Mypage.asp?&EndDate=3-5-06&StartDate=3-5-06"
Do While .busy: DoEvents: Loop
Do While .ReadyState < 4: DoEvents: Loop
End With

ie.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT
ie.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
ie.Quit

Range("A1").Select
ActiveSheet.Paste

End With

Set ie = Nothing

Exit Sub

1: MsgBox "Unexpected Error, sorry."
ie.Quit
Set ie = 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
Excel copy data Paul Gardiner Excel Worksheet Functions 2 October 15th 09 05:17 AM
How copy none excel data & paste in 2007 without overwriting data Wakefootin Excel Discussion (Misc queries) 2 October 8th 09 12:15 AM
Copy excel data (inc. textbox data) into Word Sarah (OGI) Excel Discussion (Misc queries) 0 August 14th 07 05:00 PM
How to copy data from excel to Word? Thanks for your help!! Daniel Walzenbach Excel Programming 3 May 6th 04 08:17 AM
Copy data from Excel to Access Finn Petersen Excel Programming 2 October 10th 03 01:18 PM


All times are GMT +1. The time now is 09:12 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"