PC Review


Reply
Thread Tools Rate Thread

How can I use VBA to creat new web query?

 
 
=?Utf-8?B?V2lsbA==?=
Guest
Posts: n/a
 
      28th Oct 2007
I need to build an addin application that creates a brand new web query in
the target cell / cell range. I know how to modify, refresh, but not create
a brand new query. I intend to provide a choice of several data page queries.
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      28th Oct 2007
Here's an example

With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
Connection:="URL;" & your_url,
Destination:=Worksheets("Data").Cells(1, 1))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Will" <(E-Mail Removed)> wrote in message
news:5755B129-8018-4253-8944-(E-Mail Removed)...
>I need to build an addin application that creates a brand new web query in
> the target cell / cell range. I know how to modify, refresh, but not
> create
> a brand new query. I intend to provide a choice of several data page
> queries.


 
Reply With Quote
 
=?Utf-8?B?V2lsbA==?=
Guest
Posts: n/a
 
      28th Oct 2007
Thanks that helps a lot.

This puts the table in A1 of the sheet "Data", can it be adapted to the
current selected cell?

"Don Guillett" wrote:

> Here's an example
>
> With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
> Connection:="URL;" & your_url,
> Destination:=Worksheets("Data").Cells(1, 1))
> .BackgroundQuery = True
> .TablesOnlyFromHTML = False
> .Refresh BackgroundQuery:=False
> .SaveData = True
> End With
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Will" <(E-Mail Removed)> wrote in message
> news:5755B129-8018-4253-8944-(E-Mail Removed)...
> >I need to build an addin application that creates a brand new web query in
> > the target cell / cell range. I know how to modify, refresh, but not
> > create
> > a brand new query. I intend to provide a choice of several data page
> > queries.

>
>

 
Reply With Quote
 
Mike Fogleman
Guest
Posts: n/a
 
      28th Oct 2007
Destination:=Worksheets("Data").Activecell)

Mike F

"Don Guillett" <(E-Mail Removed)> wrote in message
news:eXY%(E-Mail Removed)...
> Here's an example
>
> With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
> Connection:="URL;" & your_url,
> Destination:=Worksheets("Data").Cells(1, 1))
> .BackgroundQuery = True
> .TablesOnlyFromHTML = False
> .Refresh BackgroundQuery:=False
> .SaveData = True
> End With
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Will" <(E-Mail Removed)> wrote in message
> news:5755B129-8018-4253-8944-(E-Mail Removed)...
>>I need to build an addin application that creates a brand new web query in
>> the target cell / cell range. I know how to modify, refresh, but not
>> create
>> a brand new query. I intend to provide a choice of several data page
>> queries.

>



 
Reply With Quote
 
=?Utf-8?B?V2lsbA==?=
Guest
Posts: n/a
 
      28th Oct 2007
I have tried working with the Destination to make it the current cell. This
did not work: Destination:=ActiveSheet.Cells(ActiveCell))


"Will" wrote:

> Thanks that helps a lot.
>
> This puts the table in A1 of the sheet "Data", can it be adapted to the
> current selected cell?
>
> "Don Guillett" wrote:
>
> > Here's an example
> >
> > With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
> > Connection:="URL;" & your_url,
> > Destination:=Worksheets("Data").Cells(1, 1))
> > .BackgroundQuery = True
> > .TablesOnlyFromHTML = False
> > .Refresh BackgroundQuery:=False
> > .SaveData = True
> > End With
> >
> > --
> > Don Guillett
> > Microsoft MVP Excel
> > SalesAid Software
> > (E-Mail Removed)
> > "Will" <(E-Mail Removed)> wrote in message
> > news:5755B129-8018-4253-8944-(E-Mail Removed)...
> > >I need to build an addin application that creates a brand new web query in
> > > the target cell / cell range. I know how to modify, refresh, but not
> > > create
> > > a brand new query. I intend to provide a choice of several data page
> > > queries.

> >
> >

 
Reply With Quote
 
=?Utf-8?B?V2lsbA==?=
Guest
Posts: n/a
 
      28th Oct 2007
Thanks Mike

But that does not seem to work Here is my full code

With ActiveWorkbook.ActiveSheet _
.QueryTables.Add(Connection:="URL;mytargetpage", _
Destination:=Worksheets("sheet1").ActiveCell)
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With


"Mike Fogleman" wrote:

> Destination:=Worksheets("Data").Activecell)
>
> Mike F
>
> "Don Guillett" <(E-Mail Removed)> wrote in message
> news:eXY%(E-Mail Removed)...
> > Here's an example
> >
> > With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
> > Connection:="URL;" & your_url,
> > Destination:=Worksheets("Data").Cells(1, 1))
> > .BackgroundQuery = True
> > .TablesOnlyFromHTML = False
> > .Refresh BackgroundQuery:=False
> > .SaveData = True
> > End With
> >
> > --
> > Don Guillett
> > Microsoft MVP Excel
> > SalesAid Software
> > (E-Mail Removed)
> > "Will" <(E-Mail Removed)> wrote in message
> > news:5755B129-8018-4253-8944-(E-Mail Removed)...
> >>I need to build an addin application that creates a brand new web query in
> >> the target cell / cell range. I know how to modify, refresh, but not
> >> create
> >> a brand new query. I intend to provide a choice of several data page
> >> queries.

> >

>
>
>

 
Reply With Quote
 
Mike Fogleman
Guest
Posts: n/a
 
      28th Oct 2007
Destination:=.ActiveCell)

We were trying to do things to two different worksheets:
With ActiveWorkbook.ActiveSheet _ 'Activesheet
and then tried to
Destination:=Worksheets("sheet1").ActiveCell) 'Sheet1

Now we need:
With ActiveWorkbook.ActiveSheet _
..QueryTables.Add(Connection:="URL;mytargetpage", _
Destination:=.ActiveCell)

Mike F
"Will" <(E-Mail Removed)> wrote in message
news:E61D8171-44CB-408F-8C72-(E-Mail Removed)...
> Thanks Mike
>
> But that does not seem to work Here is my full code
>
> With ActiveWorkbook.ActiveSheet _
> .QueryTables.Add(Connection:="URL;mytargetpage", _
> Destination:=Worksheets("sheet1").ActiveCell)
> .BackgroundQuery = True
> .TablesOnlyFromHTML = False
> .Refresh BackgroundQuery:=False
> .SaveData = True
> End With
>
>
> "Mike Fogleman" wrote:
>
>> Destination:=Worksheets("Data").Activecell)
>>
>> Mike F
>>
>> "Don Guillett" <(E-Mail Removed)> wrote in message
>> news:eXY%(E-Mail Removed)...
>> > Here's an example
>> >
>> > With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
>> > Connection:="URL;" & your_url,
>> > Destination:=Worksheets("Data").Cells(1, 1))
>> > .BackgroundQuery = True
>> > .TablesOnlyFromHTML = False
>> > .Refresh BackgroundQuery:=False
>> > .SaveData = True
>> > End With
>> >
>> > --
>> > Don Guillett
>> > Microsoft MVP Excel
>> > SalesAid Software
>> > (E-Mail Removed)
>> > "Will" <(E-Mail Removed)> wrote in message
>> > news:5755B129-8018-4253-8944-(E-Mail Removed)...
>> >>I need to build an addin application that creates a brand new web query
>> >>in
>> >> the target cell / cell range. I know how to modify, refresh, but not
>> >> create
>> >> a brand new query. I intend to provide a choice of several data page
>> >> queries.
>> >

>>
>>
>>



 
Reply With Quote
 
Mike Fogleman
Guest
Posts: n/a
 
      28th Oct 2007
That didn't work either under testing, but this did:

Dim rng As Range
Set rng = ActiveCell
With ActiveWorkbook.ActiveSheet _
.QueryTables.Add(Connection:="URL;mytargetpage", _
Destination:=rng)
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With

Mike F
"Mike Fogleman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Destination:=.ActiveCell)
>
> We were trying to do things to two different worksheets:
> With ActiveWorkbook.ActiveSheet _ 'Activesheet
> and then tried to
> Destination:=Worksheets("sheet1").ActiveCell) 'Sheet1
>
> Now we need:
> With ActiveWorkbook.ActiveSheet _
> .QueryTables.Add(Connection:="URL;mytargetpage", _
> Destination:=.ActiveCell)
>
> Mike F
> "Will" <(E-Mail Removed)> wrote in message
> news:E61D8171-44CB-408F-8C72-(E-Mail Removed)...
>> Thanks Mike
>>
>> But that does not seem to work Here is my full code
>>
>> With ActiveWorkbook.ActiveSheet _
>> .QueryTables.Add(Connection:="URL;mytargetpage", _
>> Destination:=Worksheets("sheet1").ActiveCell)
>> .BackgroundQuery = True
>> .TablesOnlyFromHTML = False
>> .Refresh BackgroundQuery:=False
>> .SaveData = True
>> End With
>>
>>
>> "Mike Fogleman" wrote:
>>
>>> Destination:=Worksheets("Data").Activecell)
>>>
>>> Mike F
>>>
>>> "Don Guillett" <(E-Mail Removed)> wrote in message
>>> news:eXY%(E-Mail Removed)...
>>> > Here's an example
>>> >
>>> > With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
>>> > Connection:="URL;" & your_url,
>>> > Destination:=Worksheets("Data").Cells(1, 1))
>>> > .BackgroundQuery = True
>>> > .TablesOnlyFromHTML = False
>>> > .Refresh BackgroundQuery:=False
>>> > .SaveData = True
>>> > End With
>>> >
>>> > --
>>> > Don Guillett
>>> > Microsoft MVP Excel
>>> > SalesAid Software
>>> > (E-Mail Removed)
>>> > "Will" <(E-Mail Removed)> wrote in message
>>> > news:5755B129-8018-4253-8944-(E-Mail Removed)...
>>> >>I need to build an addin application that creates a brand new web
>>> >>query in
>>> >> the target cell / cell range. I know how to modify, refresh, but not
>>> >> create
>>> >> a brand new query. I intend to provide a choice of several data page
>>> >> queries.
>>> >
>>>
>>>
>>>

>
>



 
Reply With Quote
 
=?Utf-8?B?V2lsbA==?=
Guest
Posts: n/a
 
      28th Oct 2007
Mike - Thanks. That did it.

"Mike Fogleman" wrote:

> That didn't work either under testing, but this did:
>
> Dim rng As Range
> Set rng = ActiveCell
> With ActiveWorkbook.ActiveSheet _
> .QueryTables.Add(Connection:="URL;mytargetpage", _
> Destination:=rng)
> .BackgroundQuery = True
> .TablesOnlyFromHTML = False
> .Refresh BackgroundQuery:=False
> .SaveData = True
> End With
>
> Mike F
> "Mike Fogleman" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Destination:=.ActiveCell)
> >
> > We were trying to do things to two different worksheets:
> > With ActiveWorkbook.ActiveSheet _ 'Activesheet
> > and then tried to
> > Destination:=Worksheets("sheet1").ActiveCell) 'Sheet1
> >
> > Now we need:
> > With ActiveWorkbook.ActiveSheet _
> > .QueryTables.Add(Connection:="URL;mytargetpage", _
> > Destination:=.ActiveCell)
> >
> > Mike F
> > "Will" <(E-Mail Removed)> wrote in message
> > news:E61D8171-44CB-408F-8C72-(E-Mail Removed)...
> >> Thanks Mike
> >>
> >> But that does not seem to work Here is my full code
> >>
> >> With ActiveWorkbook.ActiveSheet _
> >> .QueryTables.Add(Connection:="URL;mytargetpage", _
> >> Destination:=Worksheets("sheet1").ActiveCell)
> >> .BackgroundQuery = True
> >> .TablesOnlyFromHTML = False
> >> .Refresh BackgroundQuery:=False
> >> .SaveData = True
> >> End With
> >>
> >>
> >> "Mike Fogleman" wrote:
> >>
> >>> Destination:=Worksheets("Data").Activecell)
> >>>
> >>> Mike F
> >>>
> >>> "Don Guillett" <(E-Mail Removed)> wrote in message
> >>> news:eXY%(E-Mail Removed)...
> >>> > Here's an example
> >>> >
> >>> > With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
> >>> > Connection:="URL;" & your_url,
> >>> > Destination:=Worksheets("Data").Cells(1, 1))
> >>> > .BackgroundQuery = True
> >>> > .TablesOnlyFromHTML = False
> >>> > .Refresh BackgroundQuery:=False
> >>> > .SaveData = True
> >>> > End With
> >>> >
> >>> > --
> >>> > Don Guillett
> >>> > Microsoft MVP Excel
> >>> > SalesAid Software
> >>> > (E-Mail Removed)
> >>> > "Will" <(E-Mail Removed)> wrote in message
> >>> > news:5755B129-8018-4253-8944-(E-Mail Removed)...
> >>> >>I need to build an addin application that creates a brand new web
> >>> >>query in
> >>> >> the target cell / cell range. I know how to modify, refresh, but not
> >>> >> create
> >>> >> a brand new query. I intend to provide a choice of several data page
> >>> >> queries.
> >>> >
> >>>
> >>>
> >>>

> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Creat Table Query Lord Kelvan Microsoft Access Queries 2 7th Oct 2008 08:17 PM
RE: Creat Table Query Jerry Whittle Microsoft Access Queries 0 6th Oct 2008 08:37 PM
How to creat a Delete query? Tiff Microsoft Access Queries 7 5th Mar 2008 09:31 PM
How to creat a Query in Code Ayo Microsoft Access 20 28th Nov 2007 06:08 PM
How to creat a query for a table =?Utf-8?B?d3VkYWlfZQ==?= Microsoft Access 1 13th Jun 2005 06:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:51 PM.