Alaska Software Inc. - validate Excel password
Username: Password:
AuthorTopic: validate Excel password
Jeanne Harrisvalidate Excel password
on Fri, 02 Jul 2010 17:02:58 -0500
How do I validate an excel password? I want to ask the user for the password 
but if it is wrong how do I not abort when I try to open the WorkBook?

I can do this:
GetPassword(@cPassword)        call a function to get the password from 
the user
oExcel := CreateObject("Excel.Application")
oExcel:Visible := .f.
oBook := oExcel:Workbooks:Open(cExcelFile,,,,,cPassword)

but if it is not valid then it aborts and gives me a Description: The 
password you supplied is not correct. ...

I would like to retry if it is not correct. Is this possable?

Jeanne
James Loughner Re: validate Excel password
on Sat, 03 Jul 2010 11:49:11 -0400
What is the value of oBook of failure?

My guess is that it is not an object at that point.

Jim

On 07/02/2010 06:02 PM, Jeanne Harris wrote:
> How do I validate an excel password? I want to ask the user for the password 
> but if it is wrong how do I not abort when I try to open the WorkBook?
> 
> I can do this:
> GetPassword(@cPassword)        call a function to get the password from 
> the user
> oExcel := CreateObject("Excel.Application")
> oExcel:Visible := .f.
> oBook := oExcel:Workbooks:Open(cExcelFile,,,,,cPassword)
> 
> but if it is not valid then it aborts and gives me a Description: The 
> password you supplied is not correct. ...
> 
> I would like to retry if it is not correct. Is this possable?
> 
> Jeanne
> 
> 
> 
>
AUGE_OHRRe: validate Excel password
on Mon, 05 Jul 2010 01:31:54 +0200
hi,

> How do I validate an excel password? I want to ask the user for the
> password but if it is wrong how do I not abort when I try to open the
> WorkBook?

try something like this :

 oExcel := CreateObject("Excel.Application")
 oExcel:Visible := .f.
 IF NIL <> oExcel
     bSaveError := ErrorBlock()
     DO WHITE .NOT. lExit
            ErrorBlock( {|e| Break(e)} )
            BEGIN SEQUENCE
                  GetPassword(@cPassword)
                  oBook := oExcel:Workbooks:Open(cExcelFile,,,,,cPassword)
                  IF NIL <> oBook
                     lExit := .T.
                  ELSE
> The  password you supplied is not correct. ...
                     BREAK
                  ENDIF
            RECOVER USING oError
> I would like to retry if it is not correct. Is this possable?
                  ErrorBlock( bSaveError )
            END SEQUENCE
      ENDDO
      ErrorBlock( bSaveError )
ENDIF

greetings by OHR
Jimmy
Jeanne HarrisRe: validate Excel password
on Mon, 05 Jul 2010 08:37:38 -0500
Good ideal but the only issue now is that with the invalid password I get 
the Excel window with its password window in the background of my 
application. The Visible set to false doesn't seem to effect it.

Jeanne

"AUGE_OHR" <AUGE_OHR*AT*WEB.DE> wrote in message 
news:6be05715$23ba35c5$11c72@news.alaska-software.com...
> hi,
>
>> How do I validate an excel password? I want to ask the user for the
>> password but if it is wrong how do I not abort when I try to open the
>> WorkBook?
>
> try something like this :
>
> oExcel := CreateObject("Excel.Application")
> oExcel:Visible := .f.
> IF NIL <> oExcel
>     bSaveError := ErrorBlock()
>     DO WHITE .NOT. lExit
>            ErrorBlock( {|e| Break(e)} )
>            BEGIN SEQUENCE
>                  GetPassword(@cPassword)
>                  oBook := oExcel:Workbooks:Open(cExcelFile,,,,,cPassword)
>                  IF NIL <> oBook
>                     lExit := .T.
>                  ELSE
>> The  password you supplied is not correct. ...
>                     BREAK
>                  ENDIF
>            RECOVER USING oError
>> I would like to retry if it is not correct. Is this possable?
>                  ErrorBlock( bSaveError )
>            END SEQUENCE
>      ENDDO
>      ErrorBlock( bSaveError )
> ENDIF
>
> greetings by OHR
> Jimmy
>
>
>
AUGE_OHRRe: validate Excel password
on Tue, 06 Jul 2010 17:46:31 +0200
hi,

> Good ideal but the only issue now is that with the invalid password I get 
> the Excel window with its password window in the background of my 
> application. The Visible set to false doesn't seem to effect it.

try oDlg::alwaysOnTop := .T. or "search" in Tasklist to bring it 
":toFront()"

greetings by OHR
Jimmy