Results 1 to 8 of 8

CurDir Doesn't Work Properly

Threaded View

  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.
    Sub TestCurDir()
        Dim DirNam  As String
        Dim Fn      As String
        
        DirNam = CurDir
        Fn = ActiveWorkbook.Name
    
    Stop
    End Sub
    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:
    RealDir = Left(ActiveWorkbook.FullName, Len(ActiveWorkbook.FullName) - Len(ActiveWorkbook.Name))
    Last edited by AliGW; 12-18-2019 at 07:00 PM. Reason: Solved tag applied - title edited.

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. [SOLVED] 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. [SOLVED] Curdir
    By Jos Vens in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2005, 08:06 AM
  8. 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