+ Reply to Thread
Results 1 to 7 of 7

VBA - Check for password protection

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Posts
    360

    VBA - Check for password protection

    I have written code to filesearch and then trawl the workbooks for any comments containing a particular string.

    However when the code is running, if a sheet is password-protected it prompts.

    Is there any way of checking to see if a file is PP'd without actually trying to open it and therefore getting prompted?

    code is as below:

    Set oBook = oExcel.Workbooks.Open(strWkShtPathAndNme, 0, True)

    CIA,
    Matt.

  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
    Hello Matt,

    Not to my knowledge. Opening the file is what places it into Excel's Workbook Collection. Until it is in the collection, VBA can't access the object's properties. Add to that password protection is an internal routine that isn't exposed outside of the Workbook. Maybe there is a way using some other language or method, but with VBA the answer is no.

    Sincerely,
    Leith Ross

  3. #3
    Curt
    Guest

    Re: VBA - Check for password protection

    I went into vba propertiers and password protected. Still after f8 puts you
    right back into the vba code. No request for password. Is ther something I am
    missing?
    Thanks

    "Leith Ross" wrote:

    >
    > Hello Matt,
    >
    > Not to my knowledge. Opening the file is what places it into Excel's
    > Workbook Collection. Until it is in the collection, VBA can't access
    > the object's properties. Add to that password protection is an internal
    > routine that isn't exposed outside of the Workbook. Maybe there is a way
    > using some other language or method, but with VBA the answer is no.
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=480862
    >
    >


  4. #4
    Norman Jones
    Guest

    Re: VBA - Check for password protection

    Hi Curt,

    After protecting the project, to activate the protection, save the workbook,
    close and re-open Excel.


    ---
    Regards,
    Norman


    "Curt" <[email protected]> wrote in message
    news:[email protected]...
    >I went into vba propertiers and password protected. Still after f8 puts you
    > right back into the vba code. No request for password. Is ther something I
    > am
    > missing?
    > Thanks
    >
    > "Leith Ross" wrote:
    >
    >>
    >> Hello Matt,
    >>
    >> Not to my knowledge. Opening the file is what places it into Excel's
    >> Workbook Collection. Until it is in the collection, VBA can't access
    >> the object's properties. Add to that password protection is an internal
    >> routine that isn't exposed outside of the Workbook. Maybe there is a way
    >> using some other language or method, but with VBA the answer is no.
    >>
    >> Sincerely,
    >> Leith Ross
    >>
    >>
    >> --
    >> Leith Ross
    >> ------------------------------------------------------------------------
    >> Leith Ross's Profile:
    >> http://www.excelforum.com/member.php...o&userid=18465
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=480862
    >>
    >>




  5. #5
    Norman Jones
    Guest

    Re: VBA - Check for password protection

    Hi Curt,

    > close and re-open Excel.


    Should have read:

    close and re-open the workbook.


    ---
    Regards,
    Norman



    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Curt,
    >
    > After protecting the project, to activate the protection, save the
    > workbook, close and re-open Excel.
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Curt" <[email protected]> wrote in message
    > news:[email protected]...
    >>I went into vba propertiers and password protected. Still after f8 puts
    >>you
    >> right back into the vba code. No request for password. Is ther something
    >> I am
    >> missing?
    >> Thanks
    >>
    >> "Leith Ross" wrote:
    >>
    >>>
    >>> Hello Matt,
    >>>
    >>> Not to my knowledge. Opening the file is what places it into Excel's
    >>> Workbook Collection. Until it is in the collection, VBA can't access
    >>> the object's properties. Add to that password protection is an internal
    >>> routine that isn't exposed outside of the Workbook. Maybe there is a way
    >>> using some other language or method, but with VBA the answer is no.
    >>>
    >>> Sincerely,
    >>> Leith Ross
    >>>
    >>>
    >>> --
    >>> Leith Ross
    >>> ------------------------------------------------------------------------
    >>> Leith Ross's Profile:
    >>> http://www.excelforum.com/member.php...o&userid=18465
    >>> View this thread:
    >>> http://www.excelforum.com/showthread...hreadid=480862
    >>>
    >>>

    >
    >




  6. #6
    Curt
    Guest

    Re: VBA - Check for password protection

    DUHHH why didn't I think of this. Found out after posting the question.
    Thanks for the reply
    Curt

    "Norman Jones" wrote:

    > Hi Curt,
    >
    > > close and re-open Excel.

    >
    > Should have read:
    >
    > close and re-open the workbook.
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Norman Jones" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi Curt,
    > >
    > > After protecting the project, to activate the protection, save the
    > > workbook, close and re-open Excel.
    > >
    > >
    > > ---
    > > Regards,
    > > Norman
    > >
    > >
    > > "Curt" <[email protected]> wrote in message
    > > news:[email protected]...
    > >>I went into vba propertiers and password protected. Still after f8 puts
    > >>you
    > >> right back into the vba code. No request for password. Is ther something
    > >> I am
    > >> missing?
    > >> Thanks
    > >>
    > >> "Leith Ross" wrote:
    > >>
    > >>>
    > >>> Hello Matt,
    > >>>
    > >>> Not to my knowledge. Opening the file is what places it into Excel's
    > >>> Workbook Collection. Until it is in the collection, VBA can't access
    > >>> the object's properties. Add to that password protection is an internal
    > >>> routine that isn't exposed outside of the Workbook. Maybe there is a way
    > >>> using some other language or method, but with VBA the answer is no.
    > >>>
    > >>> Sincerely,
    > >>> Leith Ross
    > >>>
    > >>>
    > >>> --
    > >>> Leith Ross
    > >>> ------------------------------------------------------------------------
    > >>> Leith Ross's Profile:
    > >>> http://www.excelforum.com/member.php...o&userid=18465
    > >>> View this thread:
    > >>> http://www.excelforum.com/showthread...hreadid=480862
    > >>>
    > >>>

    > >
    > >

    >
    >
    >


  7. #7
    Curt
    Guest

    Re: VBA - Check for password protection

    DUHH ain't I the dummie
    Thanks Curt

    "Norman Jones" wrote:

    > Hi Curt,
    >
    > After protecting the project, to activate the protection, save the workbook,
    > close and re-open Excel.
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Curt" <[email protected]> wrote in message
    > news:[email protected]...
    > >I went into vba propertiers and password protected. Still after f8 puts you
    > > right back into the vba code. No request for password. Is ther something I
    > > am
    > > missing?
    > > Thanks
    > >
    > > "Leith Ross" wrote:
    > >
    > >>
    > >> Hello Matt,
    > >>
    > >> Not to my knowledge. Opening the file is what places it into Excel's
    > >> Workbook Collection. Until it is in the collection, VBA can't access
    > >> the object's properties. Add to that password protection is an internal
    > >> routine that isn't exposed outside of the Workbook. Maybe there is a way
    > >> using some other language or method, but with VBA the answer is no.
    > >>
    > >> Sincerely,
    > >> Leith Ross
    > >>
    > >>
    > >> --
    > >> Leith Ross
    > >> ------------------------------------------------------------------------
    > >> Leith Ross's Profile:
    > >> http://www.excelforum.com/member.php...o&userid=18465
    > >> View this thread:
    > >> http://www.excelforum.com/showthread...hreadid=480862
    > >>
    > >>

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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