+ Reply to Thread
Results 1 to 8 of 8

CurDir Doesn't Work Properly

  1. #1
    Registered User
    Join Date
    11-06-2017
    Location
    Florida
    MS-Off Ver
    2007
    Posts
    15

    CurDir Doesn't Work Properly

    Excel 2007 CurDir acts a bit strangely. If I create a new Excel file in c:\Excel and in that file query the value of CurDir it will indeed return c:\Excel as expected.
    Please Login or Register  to view this content.
    But if I then copy that Excel file over to D:\Junk then CurDir will still return c:\Excel where the file was created, NOT the directory where the file currently resides.


    Is there some way to always find the CurDir value of where the file currently resides and is executing from?

    Thanks.

    -----------------------------------------------------------------

    A kludge solution seems to be to use ActiveWorkbook.FullName as follows:
    Please Login or Register  to view this content.
    Last edited by AliGW; 12-18-2019 at 07:00 PM. Reason: Solved tag applied - title edited.

  2. #2
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: CurDir

    hi,

    maybe : Application.ActiveWorkbook.Path
    havent checked in event of save as

    Grtz
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  3. #3
    Registered User
    Join Date
    11-06-2017
    Location
    Florida
    MS-Off Ver
    2007
    Posts
    15

    Re: CurDir

    Re: maybe : Application.ActiveWorkbook.Path

    Thanks Grtz - that looks like a cleaner solution than mine. Seems to work in a quick test of moving files around.

    Bill

  4. #4
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: CurDir

    Hi,

    If this is solved please mark it as such thx.

    Grtz

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,247

    Re: CurDir

    Administrative Note:

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    11-06-2017
    Location
    Florida
    MS-Off Ver
    2007
    Posts
    15

    Re: CurDir

    Quote Originally Posted by Joske920 View Post
    Hi,

    If this is solved please mark it as such thx.

    Grtz
    I would so mark it if I knew how. Nowhere on the page does the word "Solved" occur according to a Ctrl-F page search. And nothing equivalent jumps out at me. I've added a tag if that is what's required. Thanks.
    ----------------------

    I've manually added [Solved] to the title if that's the right approach.
    Last edited by Thales42; 12-18-2019 at 05:44 PM. Reason: Soved

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: CurDir

    Quote Originally Posted by Joske920 View Post
    hi,

    maybe : Application.ActiveWorkbook.Path
    havent checked in event of save as

    Grtz
    I have removed your advertisement from your signature - please read the rules regarding that.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: CurDir Doesn't Work Properly

    Quote Originally Posted by Thales42 View Post
    But if I then copy that Excel file over to D:\Junk then CurDir will still return c:\Excel where the file was created, NOT the directory where the file currently resides.
    This is a quirk of CurDir caused by changing to a different drive. To work around this, you need to change the drive and then change the directory.

    I have included an extract of some code below that you may find helpful.

    Please Login or Register  to view this content.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

+ 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. [SOLVED] change curdir to a folder on a network
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2020, 09:11 AM
  2. Issue with finding data source using CurDir
    By Arsi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2011, 03:15 PM
  3. curdir malfunction?
    By akolos in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-10-2007, 10:03 AM
  4. syntax: CurDir
    By Bryan Brassell in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-02-2006, 05:10 PM
  5. CurDir
    By CLR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2005, 02:55 PM
  6. CurDir in excel 2003
    By shishi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2005, 04:05 PM
  7. Curdir
    By Jos Vens in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2005, 08:06 AM
  8. [SOLVED] CurDir does not work
    By Jim73 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2005, 05:06 AM

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