+ Reply to Thread
Results 1 to 10 of 10

Issues with opening a file via a macro on different drive mappings

  1. #1
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Issues with opening a file via a macro on different drive mappings

    I have several sheets set up and have macros to open other sheets.
    My issue is the network I am on uses different drive letters for different people, (e.g. I am on T:\, but my colleague is on S:\)
    I seem to need to put in the full file path in the macro to open the sheet I need.
    Is there a way to not have to include the whole file path in the macro?

    Also, I have links to the other sheets within the original file that contains the macro.

    thanks
    Last edited by BillDoor; 01-04-2013 at 05:03 AM.

  2. #2
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: Issues with opening a file via a macro on different drive mappings

    I did try using the UNC file path, but for some reason, when the file is opened from the non-UNC file path (just opened though explorer so has T:\ as the start) it messes up the file path, it seems to add extra parts in, so the links do not work. This is all in 2007 btw

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Issues with opening a file via a macro on different drive mappings

    Is there a way to not have to include the whole file path in the macro?
    Is it ok if the macro prompts you to open the file ?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: Issues with opening a file via a macro on different drive mappings

    I'd prefer it if it didn't, as some of them are in the auto_open macro

  5. #5
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: Issues with opening a file via a macro on different drive mappings

    Hi, Is there a way to do this?

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Issues with opening a file via a macro on different drive mappings

    Bill,

    Perhaps a silly question, but is the workbook from where the code is run, perhaps on the network drive itself? In other words for you the master workbook would be stored be on T:\..\ while for another user the master workbook would be stored on S:\..\ purely because his/her home drive is mapped to another drive letter?
    If you like my contribution click the star icon!

  7. #7
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: Issues with opening a file via a macro on different drive mappings

    Hi

    yes, I suppose, I can either access the files through the T: drive, or I can go to the UNC map to get to it. My colleagues would be able to access through the two same routes, but different drive letter

  8. #8
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Issues with opening a file via a macro on different drive mappings

    Bill,

    You can use the following code to find existing mapped network drives for a user. Assuming the objects are on a specific server, you would be able to find the correct map drive dynamically.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: Issues with opening a file via a macro on different drive mappings

    Ollie

    thanks for the reply, but I can't see how this will help my problem, I don't really need to know what drive letter it is mapped to (I already kow that) what I need is a way for the macro to try and open the file on T: or S:
    thanks

  10. #10
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Issues with opening a file via a macro on different drive mappings

    Bill the drive letter mapping is different for each workstation, I get that. However in the end drives will always map to a network drive which starts with the server name. Assuming the workbook objects will always be on the same physical server you can use the code provided to determine which path is the desired one.

    A bit of example code:

    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