+ Reply to Thread
Results 1 to 7 of 7

How to set a specific directory?

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    20

    How to set a specific directory?

    Hi

    I have asked Mr. Google, but are not able to figure out how to do this. I'm sure it's easy when you know how... *S*

    We have a template that is used for logging various stuff (manually entering data and also importing thru macros). The issue is that the network setup on the various locations are not the same, and therefore I can't hardcode the file locations in the macros.

    To make things a little bit easier for the users I would like to have one place in the template where the users can set up the correct network share and folder locations. These settings should then be used in 5 different macros in different modules.

    What I need is:
    - When macro A is called it opens a file dialog box in directory 1, i.e. \\network_share\Current\Setup\Import\
    - When macro B is called it opens a file dialog box in directory 2, i.e. \\network_share\Current\Logging\Start\
    - When macro C is called it opens a file dialog box in directory 3, i.e. \\network_share\Current\Setup\Export\

    I've tried looking at Public, Private and Global Subs and Functions, but I'm not able to get this working.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to set a specific directory?

    Why exactly can't you hardcode?

    How is the setup different in each location?

    Don't the macros have to point to the same folder regardless of location?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to set a specific directory?

    Quote Originally Posted by Norie View Post
    Why exactly can't you hardcode?

    How is the setup different in each location?

    Don't the macros have to point to the same folder regardless of location?
    The network folders varies from location to location and that's why I don't want to hardcode inside each macro.

    I was probably a bit unclear on the first post, i.e. I will have to hardcode the location of the folder, but I would like to do this outside each macro to make it easier for the users.
    If I do this inside each macro it will have to be done in 5 different places, and that's not very user friendly.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to set a specific directory?

    How do you want the user to set the folder?

    Or is there some criteria you can use to set it?

  5. #5
    Registered User
    Join Date
    08-01-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to set a specific directory?

    Quote Originally Posted by Norie View Post
    How do you want the user to set the folder?

    Or is there some criteria you can use to set it?
    The best thing would be if the user can enter the neccesary information one place in a module. I have some code in "ThisWorkbook" whihc we use for some other stuff, and if I can get in there it would be more than good enough.

    Short version; As easy as possible.

    We could also use a cell in a worksheet if that makes it easier to code.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to set a specific directory?

    So the user is able to change the code?

    If they are just use a public constant declared in it's own module.

    The user can just change that as required.

  7. #7
    Registered User
    Join Date
    08-01-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: How to set a specific directory?

    Thanks for pointing me the right direction.

    If someone else needs something similar this is what I ended up with:
    Please Login or Register  to view this content.
    This is how I call the correspondent constant in each macro/sub:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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