+ Reply to Thread
Results 1 to 5 of 5

Opening an Excel Worksheet Which Is Password Protected from Editing

  1. #1
    Registered User
    Join Date
    07-24-2019
    Location
    United Kingdom
    MS-Off Ver
    2016
    Posts
    3

    Opening an Excel Worksheet Which Is Password Protected from Editing

    Hi all,

    I'm new to VBA coding, but have programmed in VB.NET for years, amongst other languages which are irrelevant to list here.

    I currently have been required to "come up with a solution to" opening an excel document with an Microsoft Access Control Panel-like page. (Well that's already done)
    The system has been set up by someone prior to myself, and I am tasked to improve some little things in the macros that manipulate the data.

    The code that opens the excel document to run a macro contained inside was taken directly from a site I stumbled upon, and I noticed the similarity straight away.

    Credit: access-excel . t i p s / run-excel-macro-from-access-vba

    The problem is, is that the excel document this access code opens is password protected from editing. So the user has to manually type the password.
    I was asked to find a way to enter the password programmatically, so the prompt for password does not popup. So I thought, there most be a way to pass in the password as command line argument when opening the file.
    But I cannot find any command line parameters that would do this.

    Now, I could write a AutoIt script to enter this password easy as pie, but I think this won't be acceptable as its a bit "screen level", but is an option I will bring up if this turns out to be impossible.

    And no, removing the password altogether is not something I have control over.

    I also saw, a method... ActiveWorkbook.unprotect(password) which may work? But I haven't tested yet, and it may not even work if the password prompt is already visible.
    Attached Images Attached Images

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Opening an Excel Worksheet Which Is Password Protected from Editing

    Hello ricci07,

    Welcome to the forum!

    The Workbooks object Open method has a named argument to allow the password to be included and not display the dialog. Since the Workbook is late bound, the arguments must be passed in order.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,006

    Re: Opening an Excel Worksheet Which Is Password Protected from Editing

    .
    #1 : Do you already have the password that is required ?

    #2 : Are you speaking of a password screen that appears immediately when you open the workbook itself ?

    #3 : Or are you speaking of the password screen that appears when you attempt to access the VBA Editing window to make changes to the VBA code ?

  4. #4
    Registered User
    Join Date
    07-24-2019
    Location
    United Kingdom
    MS-Off Ver
    2016
    Posts
    3
    Quote Originally Posted by Leith Ross View Post
    Hello ricci07,

    Welcome to the forum!

    The Workbooks object Open method has a named argument to allow the password to be included and not display the dialog. Since the Workbook is late bound, the arguments must be passed in order.

    Please Login or Register  to view this content.
    Well now I feel silly! Thanks, I will try to implement this to see it works as easy as it looks! Still trying to get used to the object model I guess

  5. #5
    Registered User
    Join Date
    07-24-2019
    Location
    United Kingdom
    MS-Off Ver
    2016
    Posts
    3
    Quote Originally Posted by Logit View Post
    .
    #1 : Do you already have the password that is required ?

    #2 : Are you speaking of a password screen that appears immediately when you open the workbook itself ?

    #3 : Or are you speaking of the password screen that appears when you attempt to access the VBA Editing window to make changes to the VBA code ?
    #1 : Not yet, but will ask for it tomorrow

    #2 : Yes, there is a prompt for password for editing, or an read only option to prevent saving

    #3 : No, when the document opens, via macro or manually

+ 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. Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  2. Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  3. Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  4. Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. Replies: 1
    Last Post: 06-23-2005, 08:05 PM
  8. Replies: 0
    Last Post: 06-23-2005, 07:05 PM

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