Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Creating QueryTable from VB6

Hi Jace,

I think you may be running into an unqualified reference error, but it's
hard to tell without seeing all the code (and that oh-so-helpful error
displayed by VB <g). See if this works:

With oXL.ActiveSheet
With .QueryTables.Add(connection:=gConnect, _
Destination:=.Range("A5"), sql:=sql$)
.Refresh
End With
End With

Notice the dot in front of Range("A5") - this way, you're explicitly telling
Excel that the range lives on the active sheet.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]

Jace wrote:
Hi,

I am trying to create an Excel addin that retrieves query statements
from a report generator and loads them as querytables in the active
worksheet. The problem I am having is when I try to execute the
QueryTables.Add method.

I have declared oXL as an object and instantiated it with

Set oXL = Application

When I execute this code...

With oXL.ActiveSheet.QueryTables.Add(connection:=gConne ct,
Destination:=Range("A5"), sql:=sql$)
.Refresh
End With

I get an error message that says "Method '~' of Object '~' failed."

The same syntax works fine if I try this from VBA, but not within my
VB6 Addin. Any ideas as to what I am doing wrong?

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
web, querytable &jpg TomR Excel Programming 0 November 4th 05 04:30 PM
Querytable range name Ray[_12_] Excel Programming 0 September 13th 04 08:29 PM
How to use QueryTable with insertion sql ou Excel Programming 1 August 18th 04 12:20 PM
Bad QueryTable Row Count igneramos[_3_] Excel Programming 0 January 27th 04 10:21 PM
Querytable Ben.c Excel Programming 4 December 3rd 03 09:11 AM


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