Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Is .xls password protected.

Thanks for the reply

I am using vb.net interop, If I try and open a workbook using
XL.Workbooks.Open("ABC.xls") without supplying a password, it prompts me for
one,.
I have DisplayAlerts = False set.

Tim


"Tom Ogilvy" wrote in message
...
Try to open it and handle the error

On Error Resume Next
set kb = Workbooks.Open("C:\MyFiles\Myfile.xls")
On Error goto 0
if kb is nothing then
msgbox "Has password"
exit sub
End if

--
Regards,
Tom Ogilvy

"Tim Marsden" wrote in message
...
Hi,

How do I tell if a .xls file has a password before I try and open it. I
don't mean a Workbook password but a file password.
The one applied when you do a save as.

Tim






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Is .xls password protected.

This is tested and works in Excel:

Sub AAATEst()
Dim wkbk As Workbook
On Error Resume Next
Set wkbk = Workbooks.Open("C:\Data6\AAABook.xls", _
Password:="", WriteResPassword:="")
On Error GoTo 0
If wkbk Is Nothing Then
MsgBox "Has Password"
End If
End Sub

It will open a workbook that is not password protected.

don't know if it will work for .Net.

--
Regards,
Tom Ogilvy


"Tim Marsden" wrote in message
...
Thanks for the reply

I am using vb.net interop, If I try and open a workbook using
XL.Workbooks.Open("ABC.xls") without supplying a password, it prompts me

for
one,.
I have DisplayAlerts = False set.

Tim


"Tom Ogilvy" wrote in message
...
Try to open it and handle the error

On Error Resume Next
set kb = Workbooks.Open("C:\MyFiles\Myfile.xls")
On Error goto 0
if kb is nothing then
msgbox "Has password"
exit sub
End if

--
Regards,
Tom Ogilvy

"Tim Marsden" wrote in message
...
Hi,

How do I tell if a .xls file has a password before I try and open it.

I
don't mean a Workbook password but a file password.
The one applied when you do a save as.

Tim








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Is .xls password protected.

Just replace "C:\Data6\AAABooks.xls" with a variable

How you populate that variable would be different in .Net than I would od it
in Excel VBA.

--
Regards,
Tom Ogilvy

"Jack" wrote in message
...
Thanks for your code Tom,
Works beautifully...
It will be even more useful if you can modify your code so that the target
file can be searched and selected from any windows directory.
Or am I asking too much?
Regards

"Tom Ogilvy" wrote in message
...
This is tested and works in Excel:

Sub AAATEst()
Dim wkbk As Workbook
On Error Resume Next
Set wkbk = Workbooks.Open("C:\Data6\AAABook.xls", _
Password:="", WriteResPassword:="")
On Error GoTo 0
If wkbk Is Nothing Then
MsgBox "Has Password"
End If
End Sub

It will open a workbook that is not password protected.

don't know if it will work for .Net.

--
Regards,
Tom Ogilvy


"Tim Marsden" wrote in message
...
Thanks for the reply

I am using vb.net interop, If I try and open a workbook using
XL.Workbooks.Open("ABC.xls") without supplying a password, it prompts

me
for
one,.
I have DisplayAlerts = False set.

Tim


"Tom Ogilvy" wrote in message
...
Try to open it and handle the error

On Error Resume Next
set kb = Workbooks.Open("C:\MyFiles\Myfile.xls")
On Error goto 0
if kb is nothing then
msgbox "Has password"
exit sub
End if

--
Regards,
Tom Ogilvy

"Tim Marsden" wrote in message
...
Hi,

How do I tell if a .xls file has a password before I try and open

it.
I
don't mean a Workbook password but a file password.
The one applied when you do a save as.

Tim












  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Is .xls password protected.

Thanks for your code Tom,
Works beautifully...
It will be even more useful if you can modify your code so that the target
file can be searched and selected from any windows directory.
Or am I asking too much?
Regards

"Tom Ogilvy" wrote in message
...
This is tested and works in Excel:

Sub AAATEst()
Dim wkbk As Workbook
On Error Resume Next
Set wkbk = Workbooks.Open("C:\Data6\AAABook.xls", _
Password:="", WriteResPassword:="")
On Error GoTo 0
If wkbk Is Nothing Then
MsgBox "Has Password"
End If
End Sub

It will open a workbook that is not password protected.

don't know if it will work for .Net.

--
Regards,
Tom Ogilvy


"Tim Marsden" wrote in message
...
Thanks for the reply

I am using vb.net interop, If I try and open a workbook using
XL.Workbooks.Open("ABC.xls") without supplying a password, it prompts me

for
one,.
I have DisplayAlerts = False set.

Tim


"Tom Ogilvy" wrote in message
...
Try to open it and handle the error

On Error Resume Next
set kb = Workbooks.Open("C:\MyFiles\Myfile.xls")
On Error goto 0
if kb is nothing then
msgbox "Has password"
exit sub
End if

--
Regards,
Tom Ogilvy

"Tim Marsden" wrote in message
...
Hi,

How do I tell if a .xls file has a password before I try and open

it.
I
don't mean a Workbook password but a file password.
The one applied when you do a save as.

Tim










  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Is .xls password protected.

Thank you for the info...

"Tom Ogilvy" wrote in message
...
Just replace "C:\Data6\AAABooks.xls" with a variable

How you populate that variable would be different in .Net than I would od

it
in Excel VBA.

--
Regards,
Tom Ogilvy

"Jack" wrote in message
...
Thanks for your code Tom,
Works beautifully...
It will be even more useful if you can modify your code so that the

target
file can be searched and selected from any windows directory.
Or am I asking too much?
Regards

"Tom Ogilvy" wrote in message
...
This is tested and works in Excel:

Sub AAATEst()
Dim wkbk As Workbook
On Error Resume Next
Set wkbk = Workbooks.Open("C:\Data6\AAABook.xls", _
Password:="", WriteResPassword:="")
On Error GoTo 0
If wkbk Is Nothing Then
MsgBox "Has Password"
End If
End Sub

It will open a workbook that is not password protected.

don't know if it will work for .Net.

--
Regards,
Tom Ogilvy


"Tim Marsden" wrote in message
...
Thanks for the reply

I am using vb.net interop, If I try and open a workbook using
XL.Workbooks.Open("ABC.xls") without supplying a password, it

prompts
me
for
one,.
I have DisplayAlerts = False set.

Tim


"Tom Ogilvy" wrote in message
...
Try to open it and handle the error

On Error Resume Next
set kb = Workbooks.Open("C:\MyFiles\Myfile.xls")
On Error goto 0
if kb is nothing then
msgbox "Has password"
exit sub
End if

--
Regards,
Tom Ogilvy

"Tim Marsden" wrote in message
...
Hi,

How do I tell if a .xls file has a password before I try and

open
it.
I
don't mean a Workbook password but a file password.
The one applied when you do a save as.

Tim














Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrive password protected worksheet but forgot password? Laurie Excel Worksheet Functions 1 November 19th 09 09:42 PM
Password protected? help!! Jason Excel Worksheet Functions 2 February 24th 06 04:16 PM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
bypass password when update linking of password protected file Yan Excel Discussion (Misc queries) 1 February 7th 05 11:29 PM
VBa, Password protected sheet fails to get unprotected with the same password Hans Rattink Excel Programming 3 July 28th 03 02:30 PM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"