ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   urgent help with lock excel macros!!! (https://www.excelbanter.com/excel-discussion-misc-queries/170826-urgent-help-lock-excel-macros.html)

[email protected]

urgent help with lock excel macros!!!
 
Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!

Could someone help me?
I post it just below and hear is the link were I found it:
http://groups.google.com/group/micro...lnk=st&q=excel

Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer

'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False

.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True

cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar

ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0

.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub

Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer

'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)

On Error Resume Next

For ctrlCount = 1 To ctrlTotal

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount

For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount

On Error GoTo 0
End With

'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub

Many thanks to everyone!
Bye,
Stefano.

FSt1

urgent help with lock excel macros!!!
 
hi
you posted 2 macros. did you run the second "unlock" macro"?

regards
FSt1

" wrote:

Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!

Could someone help me?
I post it just below and hear is the link were I found it:
http://groups.google.com/group/micro...lnk=st&q=excel

Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer

'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False

.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True

cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar

ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0

.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub

Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer

'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)

On Error Resume Next

For ctrlCount = 1 To ctrlTotal

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount

For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount

On Error GoTo 0
End With

'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub

Many thanks to everyone!
Bye,
Stefano.


[email protected]

urgent help with lock excel macros!!!
 
On 27 Dic, 14:47, FSt1 wrote:
hi
you posted 2 macros. did you run the second "unlock" macro"?

regards
FSt1

" wrote:
Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!


Could someone help me?
I post it just below and hear is the link were I found it:
http://groups.google.com/group/micro...isc/browse_thr...


Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer


'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False


.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True


cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar


ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0


.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub


Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer


'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)


On Error Resume Next


For ctrlCount = 1 To ctrlTotal


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount


For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount


On Error GoTo 0
End With


'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub


Many thanks to everyone!
Bye,
Stefano.


Yes I did it, but I run it I receive an error like that: I did not
find the unlock macros.

[email protected]

urgent help with lock excel macros!!!
 
On 27 Dic, 14:52, wrote:
On 27 Dic, 14:47, FSt1 wrote:



hi
you posted 2 macros. did you run the second "unlock" macro"?


regards
FSt1


" wrote:
Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!


Could someone help me?
I post it just below and hear is the link were I found it:
http://groups.google.com/group/micro...isc/browse_thr...


Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer


'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False


.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True


cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar


ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0


.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub


Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer


'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)


On Error Resume Next


For ctrlCount = 1 To ctrlTotal


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount


For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount


On Error GoTo 0
End With


'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub


Many thanks to everyone!
Bye,
Stefano.


Yes I did it, but I run it I receive an error like that: I did not
find the unlock macros.


I can not turn back to the normal!!
How can I do!!!!

Please help!!

FSt1

urgent help with lock excel macros!!!
 
hi
sorry i took so long. got tied up.
I have never seen this line before....
excellocked = true.

I searched vb help. keyword not found.
I searched my vb library that came with 6.0. keyword not found.
I searched microsoft.com. keyword not found.
I did a google. the only place it found the line is in the code you posted.
so i am at a loss to provide help since i don't know what that line does.
the second macros you posted seems like it would unlock excel. and since you
are having problems with the code, i don't want to test it on my pc for fear
that i might end up with the same problem.
suggestion. reinstall excel from disc. that may clear it out.
otherwize you may have to contact microsoft.

sorry i could not help
regards
FSt1

" wrote:

On 27 Dic, 14:52, wrote:
On 27 Dic, 14:47, FSt1 wrote:



hi
you posted 2 macros. did you run the second "unlock" macro"?


regards
FSt1


" wrote:
Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!


Could someone help me?
I post it just below and hear is the link were I found it:
http://groups.google.com/group/micro...isc/browse_thr...


Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer


'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False


.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True


cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar


ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0


.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub


Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer


'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)


On Error Resume Next


For ctrlCount = 1 To ctrlTotal


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount


For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount


On Error GoTo 0
End With


'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub


Many thanks to everyone!
Bye,
Stefano.


Yes I did it, but I run it I receive an error like that: I did not
find the unlock macros.


I can not turn back to the normal!!
How can I do!!!!

Please help!!


FSt1

urgent help with lock excel macros!!!
 
hi again.
I just reread the code and read the original post where you got the code.
did you press Ctrl+9? per the original post that is suppost to unlock excel.

regards
FSt1

"FSt1" wrote:

hi
sorry i took so long. got tied up.
I have never seen this line before....
excellocked = true.

I searched vb help. keyword not found.
I searched my vb library that came with 6.0. keyword not found.
I searched microsoft.com. keyword not found.
I did a google. the only place it found the line is in the code you posted.
so i am at a loss to provide help since i don't know what that line does.
the second macros you posted seems like it would unlock excel. and since you
are having problems with the code, i don't want to test it on my pc for fear
that i might end up with the same problem.
suggestion. reinstall excel from disc. that may clear it out.
otherwize you may have to contact microsoft.

sorry i could not help
regards
FSt1

" wrote:

On 27 Dic, 14:52, wrote:
On 27 Dic, 14:47, FSt1 wrote:



hi
you posted 2 macros. did you run the second "unlock" macro"?

regards
FSt1

" wrote:
Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!

Could someone help me?
I post it just below and hear is the link were I found it:
http://groups.google.com/group/micro...isc/browse_thr...

Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer

'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False

.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True

cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar

ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0

.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub

Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer

'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)

On Error Resume Next

For ctrlCount = 1 To ctrlTotal

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount

For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount

On Error GoTo 0
End With

'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub

Many thanks to everyone!
Bye,
Stefano.

Yes I did it, but I run it I receive an error like that: I did not
find the unlock macros.


I can not turn back to the normal!!
How can I do!!!!

Please help!!


FSt1

urgent help with lock excel macros!!!
 
hi again.
forget reinstalling excel.
what can you do in excel?
the code is probably in a single file. can you kill xl from the task manager?
perhaps if you reopen it (xl, not the file) it will clear itself.

regards
FSt1

"FSt1" wrote:

hi again.
I just reread the code and read the original post where you got the code.
did you press Ctrl+9? per the original post that is suppost to unlock excel.

regards
FSt1

"FSt1" wrote:

hi
sorry i took so long. got tied up.
I have never seen this line before....
excellocked = true.

I searched vb help. keyword not found.
I searched my vb library that came with 6.0. keyword not found.
I searched microsoft.com. keyword not found.
I did a google. the only place it found the line is in the code you posted.
so i am at a loss to provide help since i don't know what that line does.
the second macros you posted seems like it would unlock excel. and since you
are having problems with the code, i don't want to test it on my pc for fear
that i might end up with the same problem.
suggestion. reinstall excel from disc. that may clear it out.
otherwize you may have to contact microsoft.

sorry i could not help
regards
FSt1

" wrote:

On 27 Dic, 14:52, wrote:
On 27 Dic, 14:47, FSt1 wrote:



hi
you posted 2 macros. did you run the second "unlock" macro"?

regards
FSt1

" wrote:
Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!

Could someone help me?
I post it just below and hear is the link were I found it:
http://groups.google.com/group/micro...isc/browse_thr...

Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer

'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False

.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True

cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar

ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0

.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub

Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer

'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)

On Error Resume Next

For ctrlCount = 1 To ctrlTotal

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount

For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount

On Error GoTo 0
End With

'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub

Many thanks to everyone!
Bye,
Stefano.

Yes I did it, but I run it I receive an error like that: I did not
find the unlock macros.

I can not turn back to the normal!!
How can I do!!!!

Please help!!


iliace

urgent help with lock excel macros!!!
 
Do you have a worksheet called CommandBars?

Do you have a global declaration for excelLocked?

If your workbook doesn't have a worksheet called CommandBars, then the
macro above has no way of knowing which toolbars it disabled or hid.
You can try something like this to help you fix the problem. It will
enable ALL your command bars and menus, and it will show them. You
could prompt each time it happens, but it would take hours to do,
theoretically.

Public Sub fixLockedExcel()
With Application
On Error Resume Next
For Each cbBar In .CommandBars
cbBar.Visible = False
cbBar.Enabled = False
Next cbBar

For Each ctrl In .CommandBars.ActiveMenuBar.Controls
ctrl.Visible = True
ctrl.Enabled = True
Next ctrl
On Error GoTo 0
End With
End Sub

On Dec 27, 7:22 am, wrote:
Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!

Could someone help me?
I post it just below and hear is the link were I found it:http://groups.google.com/group/micro...isc/browse_thr...

Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer

'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False

.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True

cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar

ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0

.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub

Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer

'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)

On Error Resume Next

For ctrlCount = 1 To ctrlTotal

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True

Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount

For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount

On Error GoTo 0
End With

'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub

Many thanks to everyone!
Bye,
Stefano.



[email protected]

urgent help with lock excel macros!!!
 
On 27 Dic, 18:04, iliace wrote:
Do you have a worksheet called CommandBars?

Do you have a global declaration for excelLocked?

If your workbook doesn't have a worksheet called CommandBars, then the
macro above has no way of knowing which toolbars it disabled or hid.
You can try something like this to help you fix the problem. It will
enable ALL your command bars and menus, and it will show them. You
could prompt each time it happens, but it would take hours to do,
theoretically.

Public Sub fixLockedExcel()
With Application
On Error Resume Next
For Each cbBar In .CommandBars
cbBar.Visible = False
cbBar.Enabled = False
Next cbBar

For Each ctrl In .CommandBars.ActiveMenuBar.Controls
ctrl.Visible = True
ctrl.Enabled = True
Next ctrl
On Error GoTo 0
End With
End Sub

On Dec 27, 7:22 am, wrote:

Hi to everyone,
I was looking for a way to make Excel like viewer. Surfing in the news
group I found this macro.
It works to lock Excel but now I can't unlock Excel back!!


Could someone help me?
I post it just below and hear is the link were I found it:http://groups.google.com/group/micro...isc/browse_thr...


Public Sub LockdownExcel()
Dim objTemp As Object
Dim cbBar As CommandBar
Dim ctrl As CommandBarControl
Dim cbarCount As Integer
Dim ctrlCount As Integer


'disable keys and change settings
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Visible = False
.OnKey "^X", ""
.OnKey "^x", ""
.OnKey "^C", ""
.OnKey "^c", ""
.OnKey "^V", ""
.OnKey "^v", ""
.OnKey "^9", "ThisWorkbook.UnlockExcel"
.CutCopyMode = False
.DisplayStatusBar = False
.DisplayFormulaBar = False
.IgnoreRemoteRequests = True
.ActiveWindow.DisplayHeadings = False
.ActiveWindow.DisplayWorkbookTabs = False
.WindowState = xlMaximized
.ActiveWindow.WindowState = xlMaximized
.EnableEvents = False


.CommandBars.DisableAskAQuestionDropdown = True
.CommandBars.DisableCustomize = True


cbarCount = 0
On Error Resume Next
For Each cbBar In .CommandBars
If cbBar.Visible Then
cbarCount = cbarCount + 1
Worksheets("CommandBars").Cells(cbarCount, 1).Value =
cbBar.Name
cbBar.Visible = False
cbBar.Enabled = False
End If
Next cbBar


ctrlCount = 0
For Each ctrl In .CommandBars.ActiveMenuBar.Controls
If ctrl.Visible Then
ctrlCount = ctrlCount + 1
Worksheets("CommandBars").Cells(ctrlCount, 3).Value =
ctrl.Index
ctrl.Visible = False
ctrl.Enabled = False
End If
Next ctrl
On Error GoTo 0


.DisplayAlerts = True
.ScreenUpdating = True
.Visible = True
.EnableEvents = True
End With
excelLocked = True
End Sub


Public Sub UnlockExcel()
Dim cbBar As CommandBar
Dim cbarCount As Integer, cbarTotal As Integer
Dim ctrl As Control
Dim ctrlCount As Integer, ctrlTotal As Integer


'restore command bars
With Worksheets("CommandBars")
cbarTotal = CInt(.Cells(1, 2).Value)
ctrlTotal = CInt(.Cells(1, 4).Value)


On Error Resume Next


For ctrlCount = 1 To ctrlTotal


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Enabled = True


Application.CommandBars.ActiveMenuBar.Controls(.Ce lls(ctrlCount,
3).Value).Visible = True
.Cells(ctrlCount, 3).Value = ""
Next ctrlCount


For cbarCount = 1 To cbarTotal
Application.CommandBars(.Cells(cbarCount,
1).Value).Enabled = True
Application.CommandBars(.Cells(cbarCount,
1).Value).Visible = True
.Cells(cbarCount, 1).Value = ""
Next cbarCount


On Error GoTo 0
End With


'restore shortcut keys and other settings
With Application
.CommandBars.DisableAskAQuestionDropdown = False
.CommandBars.DisableCustomize = False
.OnKey "^X"
.OnKey "^x"
.OnKey "^C"
.OnKey "^c"
.OnKey "^V"
.OnKey "^v"
.OnKey "^9", "ThisWorkbook.LockdownExcel"
.CutCopyMode = xlCopy
.DisplayStatusBar = True
.DisplayFormulaBar = True
.IgnoreRemoteRequests = False
.ActiveWindow.DisplayHeadings = True
.ActiveWindow.DisplayWorkbookTabs = True
End With
excelLocked = False
End Sub


Many thanks to everyone!
Bye,
Stefano.


Hi, many thanks for your help.......but I'm still in trouble!
I removed all the Office installation and I reinstalled it again...and
Excel is still there with the same problems!!!!!

How can I fix it, please someone help me!!!!!!!!

Bye,
Stefano


All times are GMT +1. The time now is 12:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com