Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Skip past Password Protected Excel file

I have a routine that is going through Excel files and making a change to
every file in a specified folder.
This works great until I hit a file that's password protected. Since I don't
know the password I want to log then skip it.
Is there a way to open a workbook, not know the password, realize it has a
password and close it down and move on to the next file in the folder?

Thanks,

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Skip past Password Protected Excel file

I'm assuming that you are setting a variable to hold the workbook
currently being processed. If so, use something like this:
If wb.HasPassowrd Then
'whatever you want to happen
End If

Would need to see your code to recommend the proper spot to place
this.

koops2121 via OfficeKB.com wrote:
I have a routine that is going through Excel files and making a change to
every file in a specified folder.
This works great until I hit a file that's password protected. Since I don't
know the password I want to log then skip it.
Is there a way to open a workbook, not know the password, realize it has a
password and close it down and move on to the next file in the folder?

Thanks,

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Skip past Password Protected Excel file

Sorta yes.

I do this:

Set xApp = CreateObject("Excel.Application")
Set xBook = xApp.Workbooks.Open(objFile.Path)

If I then do xBook.HasPassword = True, it's too late and I'm already stuck at
the prompt asking for a password from the Open command. Maybe I'm doing this
wrong.

Thanks,

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200710/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Skip past Password Protected Excel file

does the workbook require a password to open it, or just to modify a worksheet?

--


Gary


"koops2121 via OfficeKB.com" <u37561@uwe wrote in message
news:797d9d9277067@uwe...
I have a routine that is going through Excel files and making a change to
every file in a specified folder.
This works great until I hit a file that's password protected. Since I don't
know the password I want to log then skip it.
Is there a way to open a workbook, not know the password, realize it has a
password and close it down and move on to the next file in the folder?

Thanks,

--
Message posted via http://www.officekb.com



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Skip past Password Protected Excel file

It requires a password to open it.
So everything hangs until you enter a password.

--
Message posted via http://www.officekb.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Skip past Password Protected Excel file

It requires a password to open it.
So everything hangs until you enter a password.

--
Message posted via http://www.officekb.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Skip past Password Protected Excel file



Dim TestWkbk as workbook
inside your looping code...
set testwkbk = nothing
on error resume next
set testwkbk = workbooks.open(filename:=theloopvaluehere,password :="")
on error goto 0
if testwkbk is nothing then
'it wasn't opened, skip it
else
'opened ok
'do the real work here.
end if
end of loop


"koops2121 via OfficeKB.com" wrote:

I have a routine that is going through Excel files and making a change to
every file in a specified folder.
This works great until I hit a file that's password protected. Since I don't
know the password I want to log then skip it.
Is there a way to open a workbook, not know the password, realize it has a
password and close it down and move on to the next file in the folder?

Thanks,

--
Message posted via http://www.officekb.com


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Skip past Password Protected Excel file

I was actually having the same problem except I was using the
Office.Interop library from a C# class and
every time I tried to open a workbook with a password an actual Excel
prompt would appear, which was no good.
The key insight for me was that entering "" as a password parameter
would cause no problems opening non password
protected files.

In my case I had to do something like this:

try{
myExcelApp.WorkBooks.Open(filename,...,"",...)
}
catch (System.runtime.InteropServices.COMException e)
{
// workbook is password-protected, gracefully exit
}

// continue with non-password-protected workbook

Thanks Dave for your elucidating post.

On Oct 10, 3:05 pm, Dave Peterson wrote:
Dim TestWkbk as workbook
inside your looping code...
set testwkbk = nothing
on error resume next
set testwkbk = workbooks.open(filename:=theloopvaluehere,password :="")
on error goto 0
if testwkbk is nothing then
'it wasn't opened, skip it
else
'opened ok
'do the real work here.
end if
end of loop

"koops2121 via OfficeKB.com" wrote:

I have a routine that is going through Excel files and making a change to
every file in a specified folder.
This works great until I hit a file that's password protected. Since I don't
know the password I want to log then skip it.
Is there a way to open a workbook, not know the password, realize it has a
password and close it down and move on to the next file in the folder?


Thanks,


--
Message posted viahttp://www.officekb.com


--

Dave Peterson



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
Referencing a password protected excel file Sungibungi Setting up and Configuration of Excel 0 July 29th 08 10:51 PM
Password protected Excel File IT Service Agent Excel Discussion (Misc queries) 1 May 20th 08 07:34 PM
Cannot open password-protected Excel File Sumit Excel Discussion (Misc queries) 0 March 6th 08 09:41 AM
Check if Excel file is password protected Christopher J Tallos Excel Programming 0 April 6th 07 05:02 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


All times are GMT +1. The time now is 02:00 PM.

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"