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: 31
Default MVP help please - dynamic pathname in ODBC arrays

Good morning. I have been at this for a couple of days already and I
can't
seem to get this to work properly. I continue to get the following
error at this point: "Not a valid file name". Below are two sets of
code, the first set works fine. The second set is the one giving me an

error. I am attempting to include a dynamic path for the query table
and to accomplish this I have tried to replace the hard-coded path with

the dynamic path "pathname" (Ingenious naming convention, I know).
The program works like this, the access DB and an Excel SS (XL1) with
the called macro (get_data) are in the same folder. Access creates a
new SS (XL2) and calls get_data from open SS (XL1). The macro
basically calls for data retrieval from an Access query in the same
folder. XL2 is saved by the user with a drop down box after the
spreadsheet has been formatted and populated. I want to keep
everything in one folder to make it easily portable. I just need to
know how to get the ODBC to work and I will have it. Any help is
greatly appreciated.


CODE1:
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=MS Access Database;DBQ=C:\Documents and
Settings\gwelsh\Desktop\Bill of
Material\MatCompile.mdb;DefaultDir=C:\Documents and" _
), Array( _
" Settings\gwelsh\Desktop\Bill of Material;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;" _
)), Destination:=Range("A1"))
.CommandText = "SELECT * FROM XL_SS_Query"


CODE 2:
Set wb2 = Workbooks(Fname)
wb2.Activate
pathname = ActiveWorkbook.Path
wb1.Activate
'
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=MS Access Database;DBQ='" & pathname &
"'\MatCompile.mdb;DefaultDir='" & pathname & "'" _
), Array( _
" ;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"

_
)), Destination:=Range("A1"))
.CommandText = "SELECT * FROM XL_SS_Query"

 
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
vlookup dynamic pathname mdhodgson Excel Discussion (Misc queries) 3 September 5th 08 03:27 AM
Using a dynamic pathname in VLOOKUP Mike D[_2_] Excel Worksheet Functions 7 July 16th 07 09:35 PM
Dynamic arrays Driver New Users to Excel 3 November 7th 05 10:11 PM
Dynamic Arrays Alan Beban[_2_] Excel Programming 12 December 9th 04 12:50 AM
LoadPicture Pathname or no Pathname Philipp Schramek Excel Programming 1 July 8th 03 03:30 PM


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