Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default how can I know if a workbook is locked?

Workbooks can be locked in a few different ways.

Do you mean that you have:

1. Worksheets that are portected via tools|protection?
2. The workbook is protected via Tools|protection?
3. The workbook is protected from opening via File|saveas|tools|...?
4. The VBA project is protected tools|vbaproject properties?

Each would have a different response.

And you may want to post a little more specifics (not a workbook) just for more
background.


guilhaume wrote:

hi all
I have a lot of excel file to unlock with a VB program
How can I know if a workbook is locked (not to try to treat them when
they are unlocked)
I tried to do:
Dim pass As String
pass= currentWorkbook.Password
If pass < "" Then
unlocking_treatment.....
End If
But even if the workbook is unlocked, the program passes into the If
condition and tries to unlock
While debuging, I saw that pass has the following value: "********"

what can I do?

Guilhaume

--
guilhaume
------------------------------------------------------------------------
guilhaume's Profile: http://www.excelforum.com/member.php...o&userid=12009
View this thread: http://www.excelforum.com/showthread...hreadid=319779


--

Dave Peterson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how can I know if a workbook is locked?


the workbook is locked by the following way:

tools - protection - protect the workbook

(I think it is that , in my case the menu options are in french... ;)

--
guilhaum
-----------------------------------------------------------------------
guilhaume's Profile: http://www.excelforum.com/member.php...fo&userid=1200
View this thread: http://www.excelforum.com/showthread.php?threadid=31977

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default how can I know if a workbook is locked?

You could just try unprotecting, then check to see if you did it successfully:

Option Explicit
Sub testme01()

Dim wkbk As Workbook
Set wkbk = ActiveWorkbook

If wkbk.ProtectWindows _
Or wkbk.ProtectStructure Then
On Error Resume Next
wkbk.Unprotect Password:="aaa"
On Error GoTo 0
If wkbk.ProtectWindows _
Or wkbk.ProtectStructure Then
MsgBox "still protectected!"
Else
MsgBox "WooHoo, Found a password"
End If
Else
MsgBox "Not protected"
End If
End Sub


You may want to take a look at J.E. McGimpsey's code that will unprotect both
the workbook and worksheets:
http://www.mcgimpsey.com/excel/removepwords.html

guilhaume wrote:

the workbook is locked by the following way:

tools - protection - protect the workbook

(I think it is that , in my case the menu options are in french... ;))

--
guilhaume
------------------------------------------------------------------------
guilhaume's Profile: http://www.excelforum.com/member.php...o&userid=12009
View this thread: http://www.excelforum.com/showthread...hreadid=319779


--

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
Shared Workbook Locked GrB Excel Discussion (Misc queries) 2 February 5th 10 06:02 PM
Workbook LOCKED - Up MrBill Excel Discussion (Misc queries) 0 November 16th 09 09:13 AM
Shared workbook locked Aram Excel Discussion (Misc queries) 0 April 29th 08 09:07 PM
Worksheets -locked out of my own workbook. Rick M Excel Discussion (Misc queries) 1 October 13th 06 11:16 PM
Open A Locked Workbook cal_yeo Excel Worksheet Functions 5 July 4th 05 03:33 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"