ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File Names (https://www.excelbanter.com/excel-programming/282237-file-names.html)

James Stephens

File Names
 
I have one last issue to finish this project. I have a program that uses multipe excel workbooks, and macros that open and access these workbooks as needed. Where my difficulty comes in is in the way they are named in the macro

Example

Workbooks.Open Filename:=
"C:\Documents and Settings\The Competitive Edge\My Documents\Inventory_Program\Inventory.xls

This works only if the person installs the program in that exact location - if not then the program can't find the file. I need to find a way, if possible, to make it so that I can reference it just from the single directory, so in this example it would be in "Inventory Program\Inventory.xls". All the workbooks that I use will be in this one directory, but all the rest depends on where it is installed on a specific computer

I hope this makes since, any help would be greatly appreciated

James

Dave Peterson[_3_]

File Names
 
Is the workbook with the code in the same folder?

If yes, then you could use this fact:

workbooks.open filename:=thisworkbook.path & "\" & "inventory.xls"



James Stephens wrote:

I have one last issue to finish this project. I have a program that uses multipe excel workbooks, and macros that open and access these workbooks as needed. Where my difficulty comes in is in the way they are named in the macro.

Example:

Workbooks.Open Filename:= _
"C:\Documents and Settings\The Competitive Edge\My Documents\Inventory_Program\Inventory.xls"

This works only if the person installs the program in that exact location - if not then the program can't find the file. I need to find a way, if possible, to make it so that I can reference it just from the single directory, so in this example it would be in "Inventory Program\Inventory.xls". All the workbooks that I use will be in this one directory, but all the rest depends on where it is installed on a specific computer.

I hope this makes since, any help would be greatly appreciated.

James


--

Dave Peterson



All times are GMT +1. The time now is 06:24 PM.

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