+ Reply to Thread
Results 1 to 8 of 8

Vba to not allow save except by certain users

  1. #1
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Vba to not allow save except by certain users

    Hi all,

    This is an interesting question. I am using this basic code in ThisWorkbook:

    Please Login or Register  to view this content.
    I was wondering if there was some way to modify this code so that only I could save the workbook. I want to be able to make changes to my template, and be able to save them. I want the user to be able to only enter in data and print to PDF the template without saving the actual workbook. I have a reset macro in the workbook to allow the user to reset the workbook to the original, but i do not want them saving the workbook. Also i think i will run into a problem later on with the fact that they have to somehow be able to save the file onto their personal computer, is there some way i guess to only allow them to save the file initially? i will be emailing them the completed file, i will not be able to modify the file after they have it. so i will not be able to send them the file without this code and just add it in later. Thanks for any help
    Regards,
    amotto

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Vba to not allow save except by certain users

    Hi, amotto11,

    you could use Environ("Username") to check who should save the fie. The instaling could be done with a different workbook copying the fie (thatīs the weak point so that anybody can copy it for themselves) or by looking at Create A Setup Utility or by using WinZip or WinRar.

    Iīd start to think about using a workbook for data and one for the code as an AddIn.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Vba to not allow save except by certain users

    HaHoBe,

    Thank you for your input, i am not familiar with Environ("Username"), would i just add this to the front of my code and asign it a name and say if name <> amotto11 or whatever the username i have is then don't allow to save?

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Vba to not allow save except by certain users

    Hi, amotto11,

    Environ("Username") is the name used to log-in to the system. Go to the Direct window and type in
    Please Login or Register  to view this content.
    Hit enter and the name will be displayed (on this computer itīs xyz for me).

    The amend your code to read (I put everything to lower case here)
    Please Login or Register  to view this content.
    You can put it your message box into the If-Statement to explain why.

    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Vba to not allow save except by certain users

    I don't know why i am having trouble today, but what is the Direct window, is this a window in excel that i am not seeing or what? thanks again

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Vba to not allow save except by certain users

    Hi, amotto11,

    itīs located in the VBE, as standard itīs not visibe if I remember correcty but can be made visible either via the menu (shoud be listed under View) or by pressing CTRL+G (at least for my german version of Excel).

    Ciao,
    Holger

  7. #7
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Vba to not allow save except by certain users

    That worked perfectly, For anyone else who is using this thread in the future the window is called the Immediate window in Excel 2010 English version.

    HAHoBe,

    Thanks you again for all of your help!

  8. #8
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Vba to not allow save except by certain users

    That worked perfectly, For anyone else who is using this thread in the future the window is called the Immediate window in Excel 2010 English version.

    HAHoBe,

    Thanks you again for all of your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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