View Full Version : Help with directory functions


graham01
11-13-2005, 12:29 PM
this is abit hard to explain and i'm new so i'm probebly not right, but..

I have made a macro that copies a certain query to an already made spreadsheet in excel, the spreadsheet will always be in the same folder as the database itself, but if both of them are placed somewhere else then macro obviously wont work because spreadsheet wont be in the folder that the macro has been told to search in... so is it possible to tell the macro that the spreadsheet will always be in the same folder as the database but not the same directory? thats as best as i can put it..i (think i) know there is a command for it, something along the lines of "$file\<spreadsheet name>.xls" but i really dont have a clue..i hope someone can help me.

many thanks,
Graham.

FoFa
11-14-2005, 06:41 AM
Have you tried the dot thing for your path?
.\MyExcelFile.xls
. means current folder
.. mean up one folder
So if it was in a folder in the current folder you could use:
.\NewFolde\MyExcelFile.xls

This only detects the CURRENT folder (sometimes know as the RUN IN folder or Start In folder in ICON properties).

graham01
11-15-2005, 11:27 AM
thanks for the reply, but this still isnt working, when i direct it to .\<filename>.xls is still copies it to My Documents :(

FoFa
11-16-2005, 06:21 AM
Then that is the default directory.
Check the FullPath property of the REFERENCE object and see if that will give you what you want. It would appear feeding it the .MDB extension would return the current path to the database, but I have not used it so am just guessing.