+ Reply to Thread
Results 1 to 7 of 7

=Cell("filename")

Hybrid View

mims =Cell("filename") 01-04-2008, 06:01 PM
shg What's wrong with what you... 01-04-2008, 06:05 PM
mims It works, but requires users... 01-04-2008, 06:14 PM
broro183 hi all, I think a better... 01-04-2008, 07:33 PM
shg Excel can do it... 01-04-2008, 08:28 PM
deadlyduck Excel has a function called... 01-05-2008, 06:23 PM
ctmurray I got this from somewhere a... 01-05-2008, 07:08 PM
  1. #1
    Registered User
    Join Date
    01-04-2008
    Posts
    2

    =Cell("filename")

    We are trying to implement and inter-office policy that requires every worksheet prepared in-house to have the filename (network storage location) on the document. Does anyone know if there is a way to get excel to do that automatically for every new document created. I don't know if it's possible, but any help would be appreciated!
    Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    What's wrong with what you have? You can add that to everyone's standard template (Book.xls).

  3. #3
    Registered User
    Join Date
    01-04-2008
    Posts
    2
    It works, but requires users to remember to enter it on each document. We were wondering if there was a way to program excel to do so automatically. I think what we were hoping is that there is an office manager function that would allow it to be applied to all docs.

  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi all,

    I think a better way than using a cell("filename") formula is incorporate it as a file footer (or header) that is in every file you open/create.

    Shg,
    I thought that it could be added to the default file/template too, but when trying it, I can't figure out how to add page footers in - can you do this?

    Mims,
    The below macros add a header & footer with "p? of ? pages" & "printed: date" and "filepath\file\worksheet tab" to the active sheet of an open file (or each sheet in the file) without changing other customised settings:

    Option Explicit
    
    Sub HdrAndFtrForCrntSht()
    'To insert a header and footer on current sheet
    Application.ScreenUpdating = False
     With ActiveSheet.PageSetup
            .RightHeader = "&8Page &P of &N"
            .LeftFooter = "&8&Z&F\&A!"
            .RightFooter = "&8Printed: &D"
        End With
    Application.ScreenUpdating = True
    End Sub
    
    Sub HeadersAndFootersForAllWkShts()
    ' Macro written by Robert Brockett 11/04/2005 - possibly modified from _
    'http://209.68.48.119/dmcritchie/excel/pathname.htm?
    Application.ScreenUpdating = False
    Dim s As Worksheet
          For Each s In ActiveWorkbook.Worksheets
           With s.PageSetup
            .RightHeader = "&8Page &P of &N"
            .LeftFooter = "&8&Z&F\&A!"
            .RightFooter = "&8Printed: &D"
        End With
        Next s
        Application.ScreenUpdating = True
    Set s = Nothing
    End Sub

    These macros could be modified/incorporated into another macro to run through a list of all existing xls files & apply the same standard header & footer but it wouldn't fix the ongoing problem of new files being created.
    Also this would wipe/change any detail that is already listed in "rightheader" etc.

    Let us know if you want further info on updating existing files en-masse or try a google or two & see what you find eg:

    http://www.google.co.nz/search?num=1...+file%22&meta=

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Excel can do it automatically, if everyone uses the same Excel template with either VBA to do it when a new workbook is instanced, or the template contains your formula.

    Office Manager is new to me.

  6. #6
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    540
    Excel has a function called =INFO("directory") which displays the path of the current directory or folder- so if you typed that into cell A1 you'd see the path to the storage location of the particular file.

    be aware, however, that the Help system advises that this function is used with caution- caveat emptor :-)

  7. #7
    Registered User
    Join Date
    11-25-2007
    Posts
    46
    I got this from somewhere a couple of years ago. It is in module 1 of the workbook. In the worksheet I have the cell call the function aname. When the workbook is opened the cell is filled with the filename. So if you change the filename by renaming using the operating system, the next time it opens it will show the new name.

    So cell A1 has the following"
    =aname()

    Function aName()
        Application.Volatile
        aName = ThisWorkbook.Name
        End Function
    The filename does not include any of the path, just the filename. Again I think people would have to use a "template" workbook which has this module.

    I did like some of the other suggestions of created headers/footers with the file name as well.

+ 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