#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default web query

Hello,
Does any one knows why the following macro not running;
sub test()

Dim a

a = Selection ' The is the selection in sheet


' where web address is given

Sheets("Sheet2").Select
Range("A1").Select
ActiveCell.FormulaR1C1 = a
With Selection.QueryTable.add(Connection:=a)

WebSelectionType = xlAllTables
WebFormatting = xlWebFormattingNone
WebPreFormattedTextToColumns = True
WebConsecutiveDelimitersAsOne = True
WebSingleBlockTextImport = False
WebDisableDateRecognition = False
Refresh BackgroundQuery:=False
End sub


regardsImran
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default web query

With Selection.QueryTable.add(Connection:=a)

First, you can't add a query to a selected cell, you add
it to the sheet and give it a destination cell. Also the
connection string requires two parts, a type and an
address. If the value in the cell is just an address, you
will need to prefix it with "URL;". Also you are missing
an End With. And you might want to clear the destination
sheet to get rid of the last web query results.

Sub Test()
Dim a
a = Selection

Sheets("Sheet2").Select
Range("A1").Select
Cells.Clear 'get rid of old stuff from prior query

With ActiveSheet.QueryTables.Add(Connection:="URL;" & a,
Destination:=Selection)
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With

End Sub

-----Original Message-----
Hello,
Does any one knows why the following macro not running;
sub test()

Dim a

a = Selection ' The is the selection in

sheet


' where web address is given

Sheets("Sheet2").Select
Range("A1").Select
ActiveCell.FormulaR1C1 = a
With Selection.QueryTable.add(Connection:=a)

.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End sub


regardsImran
.

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
Use MS Query to query data within the current work book Steve Kesler Excel Discussion (Misc queries) 0 August 6th 09 05:22 PM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


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