+ Reply to Thread
Results 1 to 3 of 3

Avoid FileNames in Code

  1. #1
    Forum Contributor
    Join Date
    05-26-2016
    Location
    India
    MS-Off Ver
    Microsoft 2021
    Posts
    324

    Question Avoid FileNames in Code

    Hello
    I need your suggestion while writing a long code
    I write a code with the help of you experts , I used More than 10 files as a source data for my code
    SO I gave them unique names and used in my code too
    If someone do not keep the exact names of those file then the macro will be failed.
    How can I avoid this type of issue
    Also I give the unique name to my Macro enable file and used that name in my code too so If Someone change the macro file name too so the code will not run
    So how can I avoid this situation too

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,714

    Re: Avoid FileNames in Code

    Many years ago when I wrote macros for others to use, I used to put my paths and filenames etc. into certain cells of a worksheet, and get that data from those cells within the macro. Another user could easily change those values to suit their own setup on their own PC.

    It is easy enough to write some error routines (with appropriate messages) to deal with a particular file not being found on the PC that the macro is running on.

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    05-26-2016
    Location
    India
    MS-Off Ver
    Microsoft 2021
    Posts
    324

    Re: Avoid FileNames in Code

    Pete, you are right we can do this I am using thisworkbook.path and filename.ext
    Is there any otherway that file name changes in folder doesnt affect my code

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to avoid repeat code
    By es19 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-30-2018, 05:23 PM
  2. VBA Code to insert photos and filenames
    By timbaliyah in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-05-2015, 03:58 AM
  3. [SOLVED] VB Code to relist filenames
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-09-2015, 03:15 PM
  4. VB Code to password protect VB Module to avoid other seeing the code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2015, 11:33 AM
  5. Can i avoid Locked Cells Using this Code getting Updated How can i edit this code
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-01-2014, 03:27 AM
  6. [SOLVED] help on vba code to avoid pop-up stage in middle of code....
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2013, 09:51 PM
  7. Replies: 9
    Last Post: 02-14-2009, 01:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1