In a protected worksheet I have been unable to trace precedent, so I have found some VBA code that achieves this for me. I have put the code in and it does trace precedents on a protected sheet by double clicking on the cell with the link. However the instructions say that there should be a temporary command bar that appears and it does not, can you help? On this temporary command bar should be an icon that can be pressed to trace precedents.
Also I would like to know how I can add this to all my workbooks so that when I send them to my colleagues overseas they can then trace precedents in protected workbooks.
teh code is as following:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
KillBar
End Sub
Private Sub Workbook_Open()
MakeBar
End Sub
**** New Code Module *****
Option Explicit
Public Const TempAuditBar = "Temp Audit Bar"
Public Const MyPassword = "integrity"
Sub MakeBar()
Dim NewMenu As CommandBar
Dim Ctrl As CommandBarControl
Dim i As Integer
KillBar
Set NewMenu = Application.CommandBars.Add(TempAuditBar… msoBarFloating, False, True)
With NewMenu
.Controls.Add Type:=msoControlButton, ID:=486
.Controls.Add Type:=msoControlButton, ID:=452
.Controls.Add Type:=msoControlButton, ID:=451
.Controls.Add Type:=msoControlButton, ID:=450
.Controls.Add Type:=msoControlButton, ID:=453
End With
For Each Ctrl In NewMenu.Controls
Ctrl.OnAction = ThisWorkbook.Name & "!TP"
Next
With NewMenu
.Visible = True
.Protection = msoBarNoChangeVisible
End With
End Sub
Sub TP()
ThisWorkbook.ActiveSheet.Unprotect MyPassword
Select Case Application.CommandBars.ActionControl.ID
Case 486
Selection.ShowPrecedents
Case 452
Selection.ShowPrecedents Remove:=True
Case 451
Selection.ShowDependents
Case 450
Selection.ShowDependents Remove:=True
Case 453
ActiveSheet.ClearArrows
End Select
ThisWorkbook.ActiveSheet.Protect MyPassword
End Sub
Sub KillBar()
On Error Resume Next
Application.CommandBars(TempAuditBar).De…
On Error Goto 0
End Sub
can somebody please tell me where I may be going wrong? Many thanks
The VBA manual I downloaded from http://www.mousetraining.co.uk/training-manuals/Excel2003VBA.pdf
doesn't seem to provide me the answer!
Cheers
R
Also I would like to know how I can add this to all my workbooks so that when I send them to my colleagues overseas they can then trace precedents in protected workbooks.
teh code is as following:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
KillBar
End Sub
Private Sub Workbook_Open()
MakeBar
End Sub
**** New Code Module *****
Option Explicit
Public Const TempAuditBar = "Temp Audit Bar"
Public Const MyPassword = "integrity"
Sub MakeBar()
Dim NewMenu As CommandBar
Dim Ctrl As CommandBarControl
Dim i As Integer
KillBar
Set NewMenu = Application.CommandBars.Add(TempAuditBar… msoBarFloating, False, True)
With NewMenu
.Controls.Add Type:=msoControlButton, ID:=486
.Controls.Add Type:=msoControlButton, ID:=452
.Controls.Add Type:=msoControlButton, ID:=451
.Controls.Add Type:=msoControlButton, ID:=450
.Controls.Add Type:=msoControlButton, ID:=453
End With
For Each Ctrl In NewMenu.Controls
Ctrl.OnAction = ThisWorkbook.Name & "!TP"
Next
With NewMenu
.Visible = True
.Protection = msoBarNoChangeVisible
End With
End Sub
Sub TP()
ThisWorkbook.ActiveSheet.Unprotect MyPassword
Select Case Application.CommandBars.ActionControl.ID
Case 486
Selection.ShowPrecedents
Case 452
Selection.ShowPrecedents Remove:=True
Case 451
Selection.ShowDependents
Case 450
Selection.ShowDependents Remove:=True
Case 453
ActiveSheet.ClearArrows
End Select
ThisWorkbook.ActiveSheet.Protect MyPassword
End Sub
Sub KillBar()
On Error Resume Next
Application.CommandBars(TempAuditBar).De…
On Error Goto 0
End Sub
can somebody please tell me where I may be going wrong? Many thanks
The VBA manual I downloaded from http://www.mousetraining.co.uk/training-manuals/Excel2003VBA.pdf
doesn't seem to provide me the answer!
Cheers
R