+ Reply to Thread
Results 1 to 9 of 9

Unlocking vba project using application.username

  1. #1
    Forum Contributor
    Join Date
    10-13-2015
    Location
    California
    MS-Off Ver
    Office 2013
    Posts
    138

    Unlocking vba project using application.username

    Hello all,

    I am curious if there is a method to unlock a vba project using application.username?

    currently I have all of my projects password protected but would like to give one other person access without him having to remember or keep track of the password.

    I use if application.username = "username" a lot of unprotect sheets and to show very hidden sheets at workbook open and am hoping i can do the same to unloack a project.

    Please let me know if there is method to unlock a vba project from within vba at workbook open.

    Thank you,

  2. #2
    Forum Contributor
    Join Date
    10-13-2015
    Location
    California
    MS-Off Ver
    Office 2013
    Posts
    138

    Re: Unlocking vba project using application.username

    Also note the method needs to work for 64bit application.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Unlocking vba project using application.username

    Unfortunately, VBA does not expose the VBProject password via object model.

    So there is no direct way of achieving what you are looking for.

    One workaround is to use SendKeys to simulate keystrokes. But this method is not particularly reliable.

    Found one such example below.
    https://www.pcreview.co.uk/threads/s...g-vba.2071944/

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Unlocking vba project using application.username

    Hi,

    There is a method that is more reliable than Sendkeys- http://www.siddharthrout.com/2013/04...that-you-know/
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Forum Contributor
    Join Date
    10-13-2015
    Location
    California
    MS-Off Ver
    Office 2013
    Posts
    138

    Re: Unlocking vba project using application.username

    Darn, I really do not want to use sendkeys on something like this.

    If anything went wrong I could be locked out of the project myself and there is hours of coding in some of them.

  6. #6
    Forum Contributor
    Join Date
    10-13-2015
    Location
    California
    MS-Off Ver
    Office 2013
    Posts
    138

    Re: Unlocking vba project using application.username

    I tried something like this http://www.siddharthrout.com/2013/04...that-you-know/ that i had found but i get a compile error on the declare statements. It says "The code in this project must be updated for use on 64-bit systems."

    Ive never seen this before have you?

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Unlocking vba project using application.username

    Yes- it means exactly what it says. The API functions have to be declared as PtrSafe and you need to update any handles and pointers to LongPtr rather than Long (mostly the hWnd variables).

    I do not have access to a 64 bit computer for testing at the moment- perhaps tomorrow.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Unlocking vba project using application.username

    You'd need to declare function as PtrSafe. It's mandatory for 64 bit systems.

    You can find detail in link below.
    https://msdn.microsoft.com/en-us/lib...ffice.14).aspx

  9. #9
    Forum Contributor
    Join Date
    10-13-2015
    Location
    California
    MS-Off Ver
    Office 2013
    Posts
    138

    Re: Unlocking vba project using application.username

    Ah gotcha.

    I think i can figure it out.

    We will see.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel Unlocking VBA Project Password
    By Excel-Guru-1987 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2016, 11:43 AM
  2. Unlocking password protected VBA project
    By samrohn77 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-29-2015, 07:37 AM
  3. unlocking with username and autolocking when save
    By angel2903 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2014, 10:50 AM
  4. [SOLVED] VBA code to change the application.username and application.userinitials
    By jwlamb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2014, 11:25 PM
  5. Unlocking a vba project within excel
    By edl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2006, 07:10 PM
  6. [SOLVED] Unlocking VBA project in Excel
    By Ramkumar Viswanathan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2006, 03:10 AM
  7. [SOLVED] Unlocking a Project
    By Ralph Heidecke in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2005, 12:45 PM

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