Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2006, 01:11 AM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help for (with ActiveSheet.QueryTables.Add Connec)

Sub WebQuery()
    Dim strSearch As String
    strSearch = "abc"

    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.xyz.com/&=" & strSearch & "", _
        Destination:=Range("A1"))
        .Name = "search?hl=en&ie=UTF-8&oe=UTF-8&q=" & strSearch & ""
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .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
************************************************** ********
Hi I want to import data from website. wht the problem is for first time the code run sucessfully but for second time it gives error at :
, Destination:=Range("A1"))

Error Description : Method 'Range' of object '_Global' failed. i.e
Run Time Error 1004.

wht I m doing is I have a list of argument every time it take one argument frm list then it goes to internet collect data from website and paste in Excel sheet then I transfer tht data to Access and clear the Excel sheet and save it after that it takes second argument and goes to internet at this time it gives above mentioned error..

Please help me with the same..
************************************************** ********





Similar Threads
Thread Thread Starter Forum Replies Last Post
QueryTables.Add - Sql parameter question deviltheone Excel VBA 0 September 26th, 2008 11:49 AM
QueryTables nested loop Sherman McCoy Excel VBA 0 June 4th, 2008 02:37 PM
QueryTables.Add... name changes peacefullAnd4getfull Excel VBA 0 May 14th, 2007 01:06 PM
With ActiveSheet Neal Excel VBA 0 May 5th, 2006 04:18 AM
Add Push button or Check Box in outlook add-ins capdevs VS.NET 2002/2003 0 January 7th, 2006 08:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.