Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2007

Tip: Looking for answers? Try searching our database.

ilia plesae help me!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
riccifs@tin.it - 27 Dec 2007 15:08 GMT
Hi ilia,
I just used a macro that you wrote time ago to hide and disable all
the Excel functionality.
But now I can not turn it back and I'm having all my Excel blocked!!!

What's wrong with that:

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(.Cells(ctrlCount,
3).Value).Enabled = True

Application.CommandBars.ActiveMenuBar.Controls(.Cells(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

Please help me or I'll need to reinstall all Office package!!!!!

Bye,
Stefano.
Jim Cone - 28 Dec 2007 11:30 GMT
Towards the bottom of your post there is a separate sub
called "UnlockExcel".  Running that sub should clean up the mess.
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

<riccifs@tin.it>
wrote in message
Hi ilia,
I just used a macro that you wrote time ago to hide and disable all
the Excel functionality.
But now I can not turn it back and I'm having all my Excel blocked!!!

What's wrong with that:

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(.Cells(ctrlCount,
3).Value).Enabled = True

Application.CommandBars.ActiveMenuBar.Controls(.Cells(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

Please help me or I'll need to reinstall all Office package!!!!!

Bye,
Stefano.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.