Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA Code problem

Hi,

I try to copy a webpage into excel as I cant import the data on the webpage
with excel web query ( I think the problem is that the data values are also
link buttons). But when I copy paste the webpage to excel manually I get the
data I need. I found a VBA code on the web that should open the webpage, copy
it all and then paste it to excel. But I always get an error message at
IE.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT
IE.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT

The problem is that I have almost no idea about VBA. Could anyone help me on
this code? and I think when it works it pastes the page in text format but I
would prefer html.....

Below is the code that should copy the google main page to excel. Thanks in
advance

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 "http://www.google.com"
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop


' 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("A1").Select
ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
False
Range("B2").Select
' Close Internet Explorer
IE.Visible = False
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
Code problem puiuluipui Excel Discussion (Misc queries) 3 July 3rd 09 07:27 PM
Problem with the following code Vince Excel Programming 3 November 19th 04 08:51 AM
vba code problem sarasa[_8_] Excel Programming 0 June 15th 04 12:33 AM
problem with this code Travis Excel Programming 1 January 28th 04 05:43 PM
Code problem Rick[_11_] Excel Programming 1 August 8th 03 04:25 AM


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