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

Hello,
I need to write a program to open and update a bunch of excel documents.
problem is, that some are password protected.
and if i hit them, then the user password dialog opens.
is there a way to tell if a document is password protected? an open
command?
so i know to skip that document?

thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 6,953
Default password protected

Dave Peterson suggested this to as similar question:

Dim wb as Workbook
For i = 1 To .FoundFiles.Count
Set wb = Nothing
On Error Resume Next
Set wb = Workbooks.Open(Filename:=.FoundFiles(i), _
Password:="", writerespassword:="")
On Error GoTo 0
If wb Is Nothing Then
'don't do anything, it wasn't opened!
MsgBox "not opened"
Else
'do your real work here
MsgBox "it's open"
End If
Next i

This was using the FileSearch Object, but you can use the approach with any
list of files.

--
Regards,
Tom Ogilvy



"greg" wrote:

Hello,
I need to write a program to open and update a bunch of excel documents.
problem is, that some are password protected.
and if i hit them, then the user password dialog opens.
is there a way to tell if a document is password protected? an open
command?
so i know to skip that document?

thanks



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

awesome!
I will give it a try




"Tom Ogilvy" wrote in message
...
Dave Peterson suggested this to as similar question:

Dim wb as Workbook
For i = 1 To .FoundFiles.Count
Set wb = Nothing
On Error Resume Next
Set wb = Workbooks.Open(Filename:=.FoundFiles(i), _
Password:="", writerespassword:="")
On Error GoTo 0
If wb Is Nothing Then
'don't do anything, it wasn't opened!
MsgBox "not opened"
Else
'do your real work here
MsgBox "it's open"
End If
Next i

This was using the FileSearch Object, but you can use the approach with

any
list of files.

--
Regards,
Tom Ogilvy



"greg" wrote:

Hello,
I need to write a program to open and update a bunch of excel documents.
problem is, that some are password protected.
and if i hit them, then the user password dialog opens.
is there a way to tell if a document is password protected? an open
command?
so i know to skip that document?

thanks





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
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
Password protected Frank Kabel Excel Programming 0 August 12th 04 12:22 AM
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 11:01 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"