LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default editing the web query through a sub

I am trying to use <get external data to get some archival data

the macro which I created and which works is

Sub Macro2()

With Selection.QueryTable
.Connection = _

"URL;http://www.nseindia.com/content/hist...JUL/cm7JUL2005
bhav.csv"
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With
End Sub

now in the url I may have to change the date from <7JUL2005 to some other
date for e.g. 8Jul2005

I tried to write the sub something like this

Public Sub newquery()
Dim scripdate As String
scripdate = InputBox("type date as for e.g. 7JUL2005")
With Selection.QueryTable
.Connection = _
"""" &
"URL;http://www.nseindia.com/content/historical/EQUITIES/2005/JUL/cm" & _
scripdate & "bhav.csv" & """"
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With

End Sub

In the input box I type 8JUL2005

But the sub stops at
..Connection = _
"""" &
"URL;http://www.nseindia.com/content/historical/EQUITIES/2005/JUL/cm" & _
scripdate & "bhav.csv" & """"

with error message
appliation defined or object defined error.

where am I doing the mistake

when I goto the <edit query and change the date 7 to 8 it works.
But I would like to automate through a sub so that the user (who may not be
comfortable with directl;y editing the query can just input the date.

of course when I succeed wtih your help I may have to do the same thing
with the month e.g JUl before "/cm" into some other month e.g. august.
excel 2000/windows 98SE
aplogise for long message.
thanks and regards



 
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
Editing MS Query Churley Excel Discussion (Misc queries) 0 November 30th 09 03:40 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
editing a query Texas Tonie[_2_] Excel Worksheet Functions 4 January 9th 08 03:19 PM
Editing external DB query harry50hn Excel Discussion (Misc queries) 0 April 7th 06 07:20 PM
Editing MS Query Patti Excel Worksheet Functions 2 December 2nd 04 01:31 PM


All times are GMT +1. The time now is 08:26 AM.

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"