Managing macros with hard coded file paths

Klint4

New Member
Joined
Oct 8, 2012
Messages
2
We have multiple macros that have been developed by various users in the company. Many of these macros have file paths hard coded into the macro to reference file locations with networked drives.

We are planning on making some changes to the network file structure which will break these macros. I realize we will have to go in and manually change all these, but it would be nice to learn from our mistake. I want to ensure that the end users have the flexibility they want, but not have to touch each macro if/when folder structures change, or files migrate to SharePoint etc.

What is the best way to manage these in the future?
ini files, master reference Excel file...,

Thank you in advance.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Welcome to the Forum, Do you know about Public Const as you can use this to retain the path for locations and much more and if you change things like servers you only have to update the Public Const and it will deal with everything else.

Example

Public Const strFilePath = "L:\Excel VBA\"

You then use the Const in code

Workbooks.Open strFilePath & "Excel Workbook Name.xls"
 
Upvote 0
So, create a module that is referenced by every macro created that requires file path information, include the Public Constants in that module. Good idea, keeps everything in the VBA development environment.
 
Upvote 0
Yes easy to manage in one place and maintain.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top