ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paths when working with macros (https://www.excelbanter.com/excel-programming/302940-paths-when-working-macros.html)

merlin63

Paths when working with macros
 
Greetings,

I recently recorded a macro that I use to import data from the sam
directory that my spreadsheet resides in. After recording, the macr
gives the full path to the spreadsheet and the Microsoft Acces
database that I am using (i.e. C:\Stuff\Morestuff\myspreadsheet.xls).

This prevents me from simply moving the files to another computer t
use, since the other computer may not be running the import in the sam
location on the hard drive.

How do I tell the spreadsheet not go to a specific directory and jus
look for the files it needs in the same directory that the origina
spreadsheet resides?

Thanks

--
Message posted from http://www.ExcelForum.com


BrianB

Paths when working with macros
 
Leave out the path, just use the workbook name. Excel automaticall
looks in the local folder first (unless you have changed i
subsequently by navigating to another folder via File/Open o
whatever). :-

myspreadsheet.xl

--
Message posted from http://www.ExcelForum.com


Jamie Collins

Paths when working with macros
 
merlin63 wrote ...

How do I tell the spreadsheet not go to a specific directory and just
look for the files it needs in the same directory that the original
spreadsheet resides?


Use:

ThisWorkbook.Path

Jamie.

--


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com