Results 1 to 8 of 8

Thread: password protect excel file

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    41

    Red face password protect excel file

    please help with how to password protect excel file using vb6, so that it can be open for modification only via vb pogram

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: password protect excel file

    For protecting

    Code:
    Osheet.Protect "Your Password"
    For unprotecting

    Code:
    Osheet.UnProtect "Your Password"
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: password protect excel file

    Please note that anyone that knows the password can open the spreadsheet external to your program, so you might want to periodically change the password.

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    41

    Re: password protect excel file

    is it possible to randomly geenerate password every time the work book closes store it in database and use it next time to open it

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: password protect excel file

    Yes it is possible. But if the database corrupts then it will be difficult (not impossible) for you to recover the password.

    MS Excel's protection has many flaws in it. It is definitely not secure. Follow what Hack suggested. Keep on changing the password manually. If possible restrict access to the workbook using Group Policies so unwanted users cannot even 'see' the file forget opening it
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  6. #6
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    688

    Re: password protect excel file

    Hi

    I have written this but it is not working

    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet

    Set xlApp = New Excel.Application
    Set xlBook = xlApp.Workbooks.Add()
    Set xlSheet = xlBook.ActiveSheet

    xlBook.SaveAs filename
    xlBook.Protect [pwd]
    xlBook.Close

    Thanks

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: password protect excel file

    Start a new thread.

    Gravedigging ancient ones is frowned upon.

  8. #8
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,835

    Re: password protect excel file

    And if you do start a new thread something more descriptiive then "it is not working" would be helpful

    Here is some free code to review that password protects:

    http://www.freevbcode.com/ShowCode.asp?ID=7312
    Last edited by TysonLPrice; Jul 3rd, 2014 at 06:18 AM.
    Please remember next time...elections matter!

Posting Permissions

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



Click Here to Expand Forum to Full Width