S
StargateFanFromWork
I've read many posts in the archives and I've managed to figure out how to
disable shortcuts in various spots, but disabling all regular XL2K print
options is eluding me. I'm only being partially successful. I also can't
seem to pinpoint a reference for any code to this in the archives so far.
My question is how do I grey out the regular print icon from the toolbar as
well as the print reference in the FILE menu. The second problem deals with
my customs icons on the toolbar, as well. I do the ^p covered; it's calling
a print macro for this workbook.
Here is what I've managed to make up. I've put this in the workbook module
with the referenced macros in a regular module (though not shown here):
*************************************************************
Private Sub Workbook_Activate()
On Error Resume Next
'Disable shortcut(s) on STANDARD toolbar, EDIT menu and cell SHORTCUT menu
With Application
.CommandBars("Standard").Controls("PRINT").Enabled = False
.CommandBars("Edit").Controls("PRINT").Enabled = False
.CommandBars("Cell").Controls("PRINT").Enabled = False
' Disable keyboard shortcuts
.OnKey "^n", ""
.OnKey "^p", ""
' enable shortcut keys to run macros
' new shortcut #1
.OnKey "^n", "AddNEWrecord"
' new shortcut #2
' enable Shift+^+R to run macro: "InsertROWS"
.OnKey "+^r", "InsertROWS"
' new shortcut #3
.OnKey "^p", "PrintSheet"
End With
End Sub
Private Sub Workbook_Deactivate()
' CommandBars disappear (whilst the workbook remains open, but another is in
view)
On Error Resume Next
'Re-enable shortcut(s) on Standard toolbar, EDIT menu, and cell SHORTCUT
menu
With Application
' these lines with TRUE are needed if you have ones with FALSE above
.CommandBars("Standard").Controls("NEW").Enabled = True
.CommandBars("Edit").Controls("NEW").Enabled = True
.CommandBars("Cell").Controls("NEW").Enabled = True
.CommandBars("Standard").Controls("PRINT").Enabled = True
.CommandBars("Edit").Controls("PRINT").Enabled = True
.CommandBars("Cell").Controls("PRINT").Enabled = True
' Re-enable NEW keyboard shortcut
.OnKey "^n"
' Re-enable Shift+Ctrl+R (just in case this ever exists)
.OnKey "+^r"
End With
End Sub
*************************************************************
One of my printer toolbar icons has a print macro in the personal.xls called
"PrintCurrentPage" assigned to it, the other 2 are icons chosen from the
commands box when customizing the toolbar.
Thank you! D
disable shortcuts in various spots, but disabling all regular XL2K print
options is eluding me. I'm only being partially successful. I also can't
seem to pinpoint a reference for any code to this in the archives so far.
My question is how do I grey out the regular print icon from the toolbar as
well as the print reference in the FILE menu. The second problem deals with
my customs icons on the toolbar, as well. I do the ^p covered; it's calling
a print macro for this workbook.
Here is what I've managed to make up. I've put this in the workbook module
with the referenced macros in a regular module (though not shown here):
*************************************************************
Private Sub Workbook_Activate()
On Error Resume Next
'Disable shortcut(s) on STANDARD toolbar, EDIT menu and cell SHORTCUT menu
With Application
.CommandBars("Standard").Controls("PRINT").Enabled = False
.CommandBars("Edit").Controls("PRINT").Enabled = False
.CommandBars("Cell").Controls("PRINT").Enabled = False
' Disable keyboard shortcuts
.OnKey "^n", ""
.OnKey "^p", ""
' enable shortcut keys to run macros
' new shortcut #1
.OnKey "^n", "AddNEWrecord"
' new shortcut #2
' enable Shift+^+R to run macro: "InsertROWS"
.OnKey "+^r", "InsertROWS"
' new shortcut #3
.OnKey "^p", "PrintSheet"
End With
End Sub
Private Sub Workbook_Deactivate()
' CommandBars disappear (whilst the workbook remains open, but another is in
view)
On Error Resume Next
'Re-enable shortcut(s) on Standard toolbar, EDIT menu, and cell SHORTCUT
menu
With Application
' these lines with TRUE are needed if you have ones with FALSE above
.CommandBars("Standard").Controls("NEW").Enabled = True
.CommandBars("Edit").Controls("NEW").Enabled = True
.CommandBars("Cell").Controls("NEW").Enabled = True
.CommandBars("Standard").Controls("PRINT").Enabled = True
.CommandBars("Edit").Controls("PRINT").Enabled = True
.CommandBars("Cell").Controls("PRINT").Enabled = True
' Re-enable NEW keyboard shortcut
.OnKey "^n"
' Re-enable Shift+Ctrl+R (just in case this ever exists)
.OnKey "+^r"
End With
End Sub
*************************************************************
One of my printer toolbar icons has a print macro in the personal.xls called
"PrintCurrentPage" assigned to it, the other 2 are icons chosen from the
commands box when customizing the toolbar.
Thank you! D