GaryTheGolfer
New Member
- Joined
- Mar 19, 2006
- Messages
- 5
Hi there,
This my first post after spending hours and hours browsing this exellent forum. I am in effect a VBA virgin and find the learning curve daunting....In other words...........Help.....please!
What I'm trying to do in WinXP :
Update an Excel 2003 spreadsheet with selected share prices from a portfolio website. My (existing) spreadsheet then manipulates and redisplays the share values and other assets as I want. Ideally I would like to import specific cellls (specific share names, price etc)....just as you would under a web query. Being unable to figure out how to do that, I decided to simply copy & paste the whole webpage on to an excel worksheet and then pick out the data from there.
[I used to have a nice little macro that worked well. It used what I think is called Web Query. Then the website added a log-in page with UserName/Password. So I started on the slippery VBA slope.]
I read the forum and "borrowed" suggested code [Thanks to contributors].
I have shown my current code below. It opens the webpage, logs on (with the correct password!), copies the webpage (as HTML). I can't get it to paste (or pasteSpecial) the webpage contents AS TEXT. It seems that it can only paste as HTML????? This is annoying given that a manual copy and pastespecial from the webpage works perfectly.....ie pastes as text not HTML
If I use just ActiveSheet.Paste, the whole webpage (with Hypertext/VBA code?) is copied into the spreadsheet....and is a real mess....trying to delete all those floating graphics seems to be a nightmare.
I am happy that I will be able to manipulate the webpage from inside the worksheet but only if it can be imported/converted to text.
Any ideas/help will be appreciated.
Thanks in Advance
This my first post after spending hours and hours browsing this exellent forum. I am in effect a VBA virgin and find the learning curve daunting....In other words...........Help.....please!
What I'm trying to do in WinXP :
Update an Excel 2003 spreadsheet with selected share prices from a portfolio website. My (existing) spreadsheet then manipulates and redisplays the share values and other assets as I want. Ideally I would like to import specific cellls (specific share names, price etc)....just as you would under a web query. Being unable to figure out how to do that, I decided to simply copy & paste the whole webpage on to an excel worksheet and then pick out the data from there.
[I used to have a nice little macro that worked well. It used what I think is called Web Query. Then the website added a log-in page with UserName/Password. So I started on the slippery VBA slope.]
I read the forum and "borrowed" suggested code [Thanks to contributors].
I have shown my current code below. It opens the webpage, logs on (with the correct password!), copies the webpage (as HTML). I can't get it to paste (or pasteSpecial) the webpage contents AS TEXT. It seems that it can only paste as HTML????? This is annoying given that a manual copy and pastespecial from the webpage works perfectly.....ie pastes as text not HTML
If I use just ActiveSheet.Paste, the whole webpage (with Hypertext/VBA code?) is copied into the spreadsheet....and is a real mess....trying to delete all those floating graphics seems to be a nightmare.
I am happy that I will be able to manipulate the webpage from inside the worksheet but only if it can be imported/converted to text.
Any ideas/help will be appreciated.
Thanks in Advance
Code:
' REMEMBER TO ENABLE <TOOLS> <REFERENCES> <MICROSOFT INTERNET CONTROLS> !!!!!!
' WebOpenPW Macro
' Macro recorded 16/03/2006 by G.L.Goodchild
' (Activate with CONTROL+w)
Sub myWebOpenPW()
' Dim IE As New InternetExplorer
Dim IE As Object
Set IE = CreateObject("InternetExplorer.application")
'Make Internet Explorer visible and go to Website
IE.Visible = True
IE.Navigate "https://www.iii.co.uk/auth/portfolio?orig_url=/portfolio&orig_server=www.iii.co.uk&orig_method=GET&"
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
' Log on to Website
Application.Wait (Now + TimeValue("0:00:3"))
IE.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
' Enter Website password (Userame is remembered)
SendKeys "123456", True
' Not the real password !!!
SendKeys "{ENTER}", True
' Wait for IE to load
Application.Wait (Now + TimeValue("0:00:10"))
' Select All Intenet Explorer data and then Copy to the clipboard
IE.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT
IE.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
Range("B17").Select
' THIS IS THE BIT THAT DOESN'T WORK :
ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
False
Range("B2").Select
' Close Internet Explorer
IE.Visible = False
End Sub