+ Reply to Thread
Results 1 to 4 of 4

Returning current file name in a cell. What's wrong with my code ?

  1. #1
    Registered User
    Join Date
    04-29-2004
    Posts
    11

    Returning current file name in a cell. What's wrong with my code ?

    Hi,

    Could someone help me to find out what is wrong in the below code ?
    It is supposed to return the name of the current file in cell I1 but it doen't work.

    Many thanks in advance,

    Greg

    VarFileName = ActiveDocument.Name
    Sheets("Sheet1").Select
    Range("I1").Value = VarFileName

  2. #2
    Registered User
    Join Date
    04-29-2004
    Posts
    11
    I've found the solution :
    VarFileName = (ThisWorkbook.Name)

  3. #3
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845
    Grek

    Change ActiveDocument.Name to ActiveWorkbook.Name

    HTH

    Charles

  4. #4
    Forum Contributor Gregor y's Avatar
    Join Date
    10-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2010 32-Bit
    Posts
    276

    Re: Returning current file name in a cell. What's wrong with my code ?

    fyi, there are also two helpful cell functions

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula: copy to clipboard
    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)

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