+ Reply to Thread
Results 1 to 3 of 3

Properties on excel file?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-02-2007
    Posts
    22

    Properties on excel file?

    Hi everybody,

    Is there any way to forbid other users to change the author name of excel file?
    Please, I realy need to know how to make this.
    Thank you verry much
    M.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Quote Originally Posted by Mm73
    Hi everybody,

    Is there any way to forbid other users to change the author name of excel file?
    Please, I realy need to know how to make this.
    Thank you verry much
    M.
    Hi,

    I can't think of any direct way of doing this. The username is a property of the Excel Application, not the Workbook level.

    There might be a workaround. You could write the user name away to a hidden cell on a protected worksheet, and then using the Workbook Before_Save event in the VBE, add the following bit of code. Assuming the username is held in a cell which you've named as 'Username'

    Application.UserName = Range("Username")
    However you need to be careful with this because you are changing the name that will get applied to all files saved by that user with their Excel Application. You'd be advised if you're going down this route to have VBA code keep track of the Usernames. So in the Workbook_Open event, capture the name of the current user and record it somewhere, say a cell called 'ApplicationOwner'. Then after the line of code above in the Before_Save event, add the line

    Application.UserName = Range("ApplicationOwner")
    HTH

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Quote Originally Posted by Richard Buttrey
    Hi,

    I can't think of any direct way of doing this. The username is a property of the Excel Application, not the Workbook level.

    There might be a workaround. You could write the user name away to a hidden cell on a protected worksheet, and then using the Workbook Before_Save event in the VBE, add the following bit of code. Assuming the username is held in a cell which you've named as 'Username'

    Application.UserName = Range("Username")
    However you need to be careful with this because you are changing the name that will get applied to all files saved by that user with their Excel Application. You'd be advised if you're going down this route to have VBA code keep track of the Usernames. So in the Workbook_Open event, capture the name of the current user and record it somewhere, say a cell called 'ApplicationOwner'. Then after the line of code above in the Before_Save event, add the line

    Application.UserName = Range("ApplicationOwner")
    HTH
    Sorry, that second line of code should be added in the Before_Close event, not the Before_Save event.

    However be aware that any other files the user opens and handles after the Save event and before the Close event, will mean that all those other files will record you as the UserName. That may be something you don't wish to happen. I suppose you could devise some code that prevented a user opening a file before you've closed this file, but then you'd still be left with other files that were already open before they opened this file. Again, you could write code to force closure of those other files so that this file is the only one open in memory, but you're getting into a potentiatally unacceptable area.

    HTH

+ 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