Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Web Query

I am trying to use excel 2003 to process online orders with a macro but am having problems with the Web Query function as follows

Cell A1 = Order number - say "1273976"

Cell A2 use excel functions "concantenate" and "hyperlink" to create the hyperlink from this order number - say http://www.anyname.com/1273976.htm

I would like cell A3 to do a Web Query based on the hyperlink in Cell A2

I have been unable to create this either with macro's or by trying to get the web query function to use the URL found in cell A2

Any ideas gratefully appreciated !!!

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dynamic Web Query

Cells/formulas don't do web queries with any built in functions. Another
question would be when should the query be performed? Should it be done on
each calculate? Should the user click a button? As far as code to do it,
turn on the macro recorder and perform the web query manually. Then in the
recorded string, replace the hard coded URL with a variable (using
concatenation). Then figure out how you want to trigger it.

the sample code for the Webtables property of the querytable object shows
this:

Set shFirstQtr = Workbooks(1).Worksheets(1)
Set qtQtrResults = shFirstQtr.QueryTables _
.Add(Connection := "URL;http://datasvr/98q1/19980331.htm", _
Destination := shFirstQtr.Cells(1,1))
With qtQtrResults
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1,2"
.Refresh
End With

So you would modify such code like

Dim sh as Worksheet
sh = worksheets("Sheet1")
Set shFirstQtr = Workbooks(1).Worksheets(1)
Set qtQtrResults = shFirstQtr.QueryTables _
.Add(Connection := "URL;" & sh.Range("A2").Value, _
Destination := shFirstQtr.Cells(1,1))
With qtQtrResults
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1,2"
.Refresh
End With



as an example.
-- Regards,Tom Ogilvy"Amanda MMW" <Amanda
wrote in message ...
I am trying to use excel 2003 to process online orders with a macro but am

having problems with the Web Query function as follows

Cell A1 = Order number - say "1273976"

Cell A2 use excel functions "concantenate" and "hyperlink" to create the

hyperlink from this order number - say
http://www.anyname.com/1273976.htm

I would like cell A3 to do a Web Query based on the hyperlink in Cell A2

I have been unable to create this either with macro's or by trying to get

the web query function to use the URL found in cell A2

Any ideas gratefully appreciated !!!

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Web Query

Hi Tom

Many thanks for the suggestion - unfortunately this produces syntax error: "object required"

herewith the macro originally recorded with a static URL:

Sub testerRefresh()
'
' testerRefresh Macro
' Macro recorded 6/12/2004 by AA
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://anydomain.com/servlet/OrderUpdate?orderid=15360988", _
Destination:=Range("A3"))
.Name = "OrderUpdate"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingRTF
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=True
End With
End Sub

Replacing in this macro the following lines:

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://anydomain.com/servlet/OrderUpdate?orderid=15360988", _

with your suggestion to obtain the URL value from the active worksheet cell A2:

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & sh.Range("A2").Value, _

produces "syntax error" "object required"

In answer to your questions regarding the
"when should the query be performed? Should it be done on
each calculate? Should the user click a button?"
- the query should be performed each time the macro is run

Any ideas??

Thanks




"Tom Ogilvy" wrote:

Cells/formulas don't do web queries with any built in functions. Another
question would be when should the query be performed? Should it be done on
each calculate? Should the user click a button? As far as code to do it,
turn on the macro recorder and perform the web query manually. Then in the
recorded string, replace the hard coded URL with a variable (using
concatenation). Then figure out how you want to trigger it.

the sample code for the Webtables property of the querytable object shows
this:

Set shFirstQtr = Workbooks(1).Worksheets(1)
Set qtQtrResults = shFirstQtr.QueryTables _
.Add(Connection := "URL;http://datasvr/98q1/19980331.htm", _
Destination := shFirstQtr.Cells(1,1))
With qtQtrResults
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1,2"
.Refresh
End With

So you would modify such code like

Dim sh as Worksheet
sh = worksheets("Sheet1")
Set shFirstQtr = Workbooks(1).Worksheets(1)
Set qtQtrResults = shFirstQtr.QueryTables _
.Add(Connection := "URL;" & sh.Range("A2").Value, _
Destination := shFirstQtr.Cells(1,1))
With qtQtrResults
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1,2"
.Refresh
End With



as an example.
-- Regards,Tom Ogilvy"Amanda MMW" <Amanda
wrote in message ...
I am trying to use excel 2003 to process online orders with a macro but am

having problems with the Web Query function as follows

Cell A1 = Order number - say "1273976"

Cell A2 use excel functions "concantenate" and "hyperlink" to create the

hyperlink from this order number - say
http://www.anyname.com/1273976.htm

I would like cell A3 to do a Web Query based on the hyperlink in Cell A2

I have been unable to create this either with macro's or by trying to get

the web query function to use the URL found in cell A2

Any ideas gratefully appreciated !!!

Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dynamic Web Query

Assuming that since it is a URL, that excel turns it into a hyperlink, this
worked for me:

Sub Tester1()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & Range("C1").Hyperlinks(1).Address, _
Destination:=Range("A3"))
.Name = "OrderUpdate"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingRTF
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
' .WebDisableRedirections = False
.Refresh BackgroundQuery:=True
End With
End Sub

--
Regards,
Tom Ogilvy

"Amanda MMW" wrote in message
...
Hi Tom

Many thanks for the suggestion - unfortunately this produces syntax error:

"object required"

herewith the macro originally recorded with a static URL:

Sub testerRefresh()
'
' testerRefresh Macro
' Macro recorded 6/12/2004 by AA
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://anydomain.com/servlet/OrderUpdate?orderid=15360988",

_
Destination:=Range("A3"))
.Name = "OrderUpdate"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingRTF
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=True
End With
End Sub

Replacing in this macro the following lines:

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://anydomain.com/servlet/OrderUpdate?orderid=15360988", _

with your suggestion to obtain the URL value from the active worksheet

cell A2:

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & sh.Range("A2").Value, _

produces "syntax error" "object required"

In answer to your questions regarding the
"when should the query be performed? Should it be done on
each calculate? Should the user click a button?"
- the query should be performed each time the macro is run

Any ideas??

Thanks




"Tom Ogilvy" wrote:

Cells/formulas don't do web queries with any built in functions.

Another
question would be when should the query be performed? Should it be done

on
each calculate? Should the user click a button? As far as code to do

it,
turn on the macro recorder and perform the web query manually. Then in

the
recorded string, replace the hard coded URL with a variable (using
concatenation). Then figure out how you want to trigger it.

the sample code for the Webtables property of the querytable object

shows
this:

Set shFirstQtr = Workbooks(1).Worksheets(1)
Set qtQtrResults = shFirstQtr.QueryTables _
.Add(Connection := "URL;http://datasvr/98q1/19980331.htm", _
Destination := shFirstQtr.Cells(1,1))
With qtQtrResults
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1,2"
.Refresh
End With

So you would modify such code like

Dim sh as Worksheet
sh = worksheets("Sheet1")
Set shFirstQtr = Workbooks(1).Worksheets(1)
Set qtQtrResults = shFirstQtr.QueryTables _
.Add(Connection := "URL;" & sh.Range("A2").Value, _
Destination := shFirstQtr.Cells(1,1))
With qtQtrResults
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1,2"
.Refresh
End With



as an example.
-- Regards,Tom Ogilvy"Amanda MMW" <Amanda
wrote in message

...
I am trying to use excel 2003 to process online orders with a macro

but am
having problems with the Web Query function as follows

Cell A1 = Order number - say "1273976"

Cell A2 use excel functions "concantenate" and "hyperlink" to create

the
hyperlink from this order number - say

http://www.anyname.com/1273976.htm

I would like cell A3 to do a Web Query based on the hyperlink in Cell

A2

I have been unable to create this either with macro's or by trying to

get
the web query function to use the URL found in cell A2

Any ideas gratefully appreciated !!!

Thanks






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
MS Query - Dynamic Data Source? xirus Setting up and Configuration of Excel 0 December 30th 09 11:18 AM
Dynamic URL for first column of data from excel query? Edgeline Excel Discussion (Misc queries) 1 October 8th 07 12:11 PM
Dynamic URL for first column of data from excel query? Edgeline Excel Discussion (Misc queries) 0 October 8th 07 03:29 AM
Dynamic web query in Excel 2003 Farhomer Excel Discussion (Misc queries) 0 October 3rd 06 10:53 PM
db query with dynamic criteria Stanley Excel Discussion (Misc queries) 1 January 19th 06 07:47 PM


All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"