Consulting

Results 1 to 7 of 7

Thread: Solved: Preventing a user from saving a file as a different name.

  1. #1
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location

    Solved: Preventing a user from saving a file as a different name.

    Is there a way to prevent a user from changing the name of a workbook by using ?saving as??
    Would the code be inserted into the workbook/beforesave section?

    Thanks once again???..

  2. #2
    Hi ,

    The following code should work:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If SaveAsUI Then Cancel = True
    End Sub

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Maybe a slight change to force it as a normal save

    [vba]

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim sFile
    If SaveAsUI Then
    Application.EnableEvents = False
    Cancel = True
    ThisWorkbook.Save
    End If
    Application.EnableEvents = True
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    372
    Location
    If the user's security is set to high, none of this matters anyways and they can save it however they like, correct?

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    True, macros will be automatically disabled. Does anyone actually use that? I know some It departments impose a no-macro rule, but I bet not many people set it high themselves.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location
    Thanks a lot again! It works perfect??
    As for the Macro security setting, the user needs to have the macros enabled for the app to work for them anyway and I am only worried about the majority of the users not the ones that like to tear things apart to see how they work.

    Those ones are pretty hard to control without a small (or large) electrical pulse that emanates from their keyboard when entering somewhere they shouldn?t be.

    Is that option under the application or workbook section? LOL

    Thanks again for all your help?..

  7. #7
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    372
    Location
    Yeah - I know both my former and current employers default excel to high security.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •