Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a Macro or VBA copy a Webpage and Paste it into Excel

Status
Not open for further replies.

RobittyBob

Technical User
Jan 8, 2002
6
NZ
Hi, already have a partly finished macro which will open up a certain webpage/s, through Hperlinks. Once the webpage is open I can manually SelectAll then Copy then go to the Excel Worksheet and Paste it to "A1" and it spreads itself nicely over the worksheet at which level I will apply code that will check for errors in the Document.

I don't want the entire sheet to be into one cell unless it is possible to later spread it out again.

We are using Internet Explorer as the WebBrowser and Windows NT.
Could I be asking the Impossible as there is not much written on this subject on the Internet.
Thanks
RobbityBob
 
Have you tried

from the menu

Data>Get external data>new web query...


follow the wizard from there.
 
Thanks ETID I am trying that option as well, but have a feeling that option will be turned off by the IT people.

Is there a way to activate the CommandBars and Controls Edit and Copy and Paste if this functionality has been deactivated.
RobbityBob

 
Code:
 Sub WebAccessTest()
'
' WebAccessTest Macro
'
 
'
    ActiveSheet.Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;[URL unfurl="true"]http://www."your[/URL] web address here and file to query" ", Destination:=Range _
        ("A1"))   'Where you want it placed on ActiveSheet
        .Name = "index"   'What you want the Query to be called
        .FieldNames = True  'Some of these may need blocking 
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlAllTables
        .WebFormatting = xlWebFormattingAll
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .Refresh BackgroundQuery:=False
    End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top