+ Reply to Thread
Results 1 to 17 of 17

Unprotect VBEproject password in second workbook

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Unprotect VBEproject password in second workbook

    Hi Guys,

    i have code:

    Please Login or Register  to view this content.
    Code is trying to open second workbook with pass for VBEproject and use sendkeys to unprotect it.
    But sendkeys is adding password into current module...

    How to do this properly?

    I am adding 2 example workbooks.
    One with code above and one with password for VBEproject = "1234"

    Can you please help?

    Jacek
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    The issue here is very complex and difficult.
    I found spme others code (more complicated) but they are not working for me.

    For example here:


    http://www.vbaexpress.com/forum/show...les)-using-vba

    Please Login or Register  to view this content.
    Oh please help i ahve about 100 hundreds workbooks to unlock....

    Best,
    Jacek

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    Ok,

    my fight with unclocking password continuity...

    I used this code and achive to open:

    Please Login or Register  to view this content.
    Screenshot_16.png

    If i could somehow go to "Protection" tab and untick would be awesome.
    I do not know also how this will be working while opening 100 hundreds workbooks. If i have to do them visible or not? ...

    Please help,
    Jacek

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,415

    Re: Unprotect VBEproject password in second workbook

    Did you mean to attach a workbook for testing?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    Hi Ali,

    workbooks attached in first topic.

    Best,
    Jacek

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,415

    Re: Unprotect VBEproject password in second workbook

    Sorry - I misunderstood your last post.

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    ok Guys,

    i stucked.
    What i achevied is getting microsoft spy ++ and tracking windows in system:

    Attachment 672829

    I have to somehow refer to this window:

    my code which i added:

    Please Login or Register  to view this content.
    Maybe there is other simpler way?
    Or do you know windows api functions?

    Best,
    Jacek

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: Unprotect VBEproject password in second workbook

    Do you actually have the password for this file?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  9. #9
    Registered User
    Join Date
    04-16-2020
    Location
    Poland
    MS-Off Ver
    2013+
    Posts
    3

    Re: Unprotect VBEproject password in second workbook

    hej Jacek,

    Sprawdz to

    Apologies for polish lng ;-)
    Tested on Excel 2010 x64 (...Ptr variable)


    Please Login or Register  to view this content.
    --
    Piotr
    Last edited by nicker; 04-16-2020 at 05:20 PM.

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: Unprotect VBEproject password in second workbook

    Please respond to my question in post 8.

    No further help to be offered until OP responds to my question!

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    Hi FDibbinis,

    yes i have password.

    Thank you nicker! (dziękuje Ci Piotr!)
    Your code is mastery!

    Few questions:
    1. How to debug it? When This timer stops - it is crashing my app.
    2. If i want to set password once again after doing changes in another workbook how can i do this? It is the easy way to do this?
    3. Macro is very fast!
    4. LockWindowUpdate 0 --> it is only in the end of code, where are you locking this first?

    Thank you for help and support.
    It is very nice method!

    Jacek

  12. #12
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    Ok Guys,

    for question 2 i have answer: i do not have to protect workbook using code because when it is saved it still has the password.
    Password is taken, operations done, workbook saved but workbook still has the password. Hmm but...why? It should take off password constantly?

    the code:

    Please Login or Register  to view this content.
    throws for me runtime error while working on my big workbooks (17 MB) so i changed this to simple:
    Please Login or Register  to view this content.
    and works perfectly.

    Jacek

  13. #13
    Registered User
    Join Date
    04-16-2020
    Location
    Poland
    MS-Off Ver
    2013+
    Posts
    3

    Re: Unprotect VBEproject password in second workbook

    Hi Jacek,

    The answers for your questions:

    1) You cannot debug directly (during processing) because there are timer-events (with callbacks), to debug you can
    run
    Please Login or Register  to view this content.
    inside the code or REM lines with timer calls function i.e: LockWindowUpdate, SetTimer etc.
    2) To setting password/locking project you need to handle 'vbaproject properties' window and change formants using winapi functions
    such as: SendMessage and change below piece of code to your own password using REPLACE_PASSWORD const :
    Please Login or Register  to view this content.
    3) yes, indeed
    4) simply -
    Please Login or Register  to view this content.
    but in general some of winapi functions like SendMessage can freeze window that's why is
    necessary to "un-freeze" them in case of unexpected events (used in error handlers clause)


    Additionaly, I've added part of code for unlocking project (not only "writing" password on first, modal window) and saving everything
    so you will able to open your "unlocked" workbooks (there wasn't in previous version of code), please find enclosed file.

    hope, it'll help...
    Attached Files Attached Files
    Last edited by nicker; 04-18-2020 at 07:52 AM.

  14. #14
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    Hi nicker,

    thank you so much!
    Code is awesome.

    Ok so in your first code password was only inputted to unlock workbook but not unlock forever and in attachment it is unlocking constantly yes?

    One more question,
    how this code is risky? I mean it is using not Excel inbuilt objects but also external code - windows api.

    Best,
    Jacek

  15. #15
    Registered User
    Join Date
    04-16-2020
    Location
    Poland
    MS-Off Ver
    2013+
    Posts
    3

    Re: Unprotect VBEproject password in second workbook

    Hi,

    1) yes, in first version is inputed password to "VBAProject Password" window, on this one the same + uncheck "lock" checkbox and replace password to empty string
    and obviously save everything.

    2) What does it mean "risky" in your opinion? You mean some winapi function will be not accessible or else - if yes, this code is for X64 windows only and uses standard winapi function so should be ready to you from winxp to win10 I guess.

  16. #16
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    O wow this is awesome!

    Thank you!

    Jacek

  17. #17
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Unprotect VBEproject password in second workbook

    Hi Guys,

    i wrote similar, shorter code:

    Please Login or Register  to view this content.
    Can anybody tell me why this code is not working? It can be goo, simpler approach?

    When i am opening Excel with password as new isntance --> it is working. If not, it can not find the window.
    nicker, i tried to use your methods:

    Please Login or Register  to view this content.
    to set VBE in opened workbook but they failed. It is opening VBE oroject properties in main workbook. Why?
    Can anybody help?

    Jacek
    Last edited by jaryszek; 04-19-2020 at 04:57 AM.

+ 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. [SOLVED] Unprotect Workbook Enter Password One Time
    By fredfarmer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2019, 05:05 AM
  2. [SOLVED] Unprotect & Protect All workbook sheets password protection / existing code help needed
    By annazet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2017, 04:51 PM
  3. [SOLVED] Error on password unprotect macro upon workbook open event
    By phpolicylady in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-13-2015, 02:00 PM
  4. Replies: 0
    Last Post: 03-12-2013, 02:33 AM
  5. How to unprotect a workbook if the password is lost
    By CantripGhost in forum Excel General
    Replies: 2
    Last Post: 12-21-2010, 09:50 AM
  6. [SOLVED] Record a macro which enters a password to unprotect a workbook
    By Zeon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2006, 03:25 PM
  7. [SOLVED] Unprotect workbook without password
    By Maria K Brickl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2005, 02:05 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