Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default SQL script to select another file in same folder

My code below needs another line to identify the workbook path is where the
folder where the workbook resides.

SELECT data.heading1, data.heading2
FROM [Excel 8.0;HDR=Yes;database=.\book1.xls";].[Data]

I would like this MS Query in Excel to link with the file book1.xls, which
is located in the same folder as the open (active) workbook. However, the
system thinks the activeworkbook path is that shown in my default settings
(Tools-Options-General-Default Path).

Thank you for your help.

Thank ytou.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default SQL script to select another file in same folder

Can't you just build it up

sFile = Activeworkbook.Path & Application.PathSeparator & "Book1.xls"

sSQL = "SELECT data.heading1, data.heading2 FROM [Excel
8.0;HDR=Yes;database=." & sFile & "";].[Data]"


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"RiverGully" wrote in message
...
My code below needs another line to identify the workbook path is where
the
folder where the workbook resides.

SELECT data.heading1, data.heading2
FROM [Excel 8.0;HDR=Yes;database=.\book1.xls";].[Data]

I would like this MS Query in Excel to link with the file book1.xls, which
is located in the same folder as the open (active) workbook. However, the
system thinks the activeworkbook path is that shown in my default settings
(Tools-Options-General-Default Path).

Thank you for your help.

Thank ytou.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default SQL script to select another file in same folder

Bob, I copy and pasted the new statements into the Microsoft Query (Excel's
Data - Import External Data -..Database Query) and got the message "Invalid
SQL statement; expected Delete, Insert, Procedure, Select or Update".

Is there another way? Thank you.


"Bob Phillips" wrote:

Can't you just build it up

sFile = Activeworkbook.Path & Application.PathSeparator & "Book1.xls"

sSQL = "SELECT data.heading1, data.heading2 FROM [Excel
8.0;HDR=Yes;database=." & sFile & "";].[Data]"


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"RiverGully" wrote in message
...
My code below needs another line to identify the workbook path is where
the
folder where the workbook resides.

SELECT data.heading1, data.heading2
FROM [Excel 8.0;HDR=Yes;database=.\book1.xls";].[Data]

I would like this MS Query in Excel to link with the file book1.xls, which
is located in the same folder as the open (active) workbook. However, the
system thinks the activeworkbook path is that shown in my default settings
(Tools-Options-General-Default Path).

Thank you for your help.

Thank ytou.




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
Save file in a new folder, but create folder only if folder doesn't already exist? nbaj2k[_40_] Excel Programming 6 August 11th 06 08:41 PM
Selecting the most recent file in a folder by Macro/VBA script [email protected] Excel Programming 3 July 20th 06 06:06 PM
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
"Folder Select" Dialogue - Opening multiple files from selected folder Rob[_26_] Excel Programming 2 September 30th 05 02:47 PM


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