Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
I asked a question earlier about restoring my command menu. I got it t work. I am using this program. I know want to make it just leave print icon of some type. Here is the code I am using Private Sub Workbook_Activate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = False Next End Sub Private Sub Workbook_Deactivate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = True Next End Sub I guess I need one in between to add the print menu. Mik ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
Hi mikegospo
You can use something like this or use the CTRL-P shortcut with your other code to print Sub MakeToolBar() Dim bar As CommandBar On Error Resume Next Application.CommandBars("MyToolBar").Delete On Error GoTo 0 For Each bar In Application.CommandBars bar.Enabled = False Next With Application.CommandBars.Add(Name:="myToolBar", Position:=msoBarTop, MenuBar:=False) .Protection = msoBarNoCustomize ' Prevent users from accessing the Add or Remove Buttons menu ' this will add a default Excel button .Controls.Add Type:=msoControlButton, ID:=4 .Visible = True End With End Sub Sub DeleteToolBar() Dim bar As CommandBar On Error Resume Next Application.CommandBars("MyToolBar").Delete On Error GoTo 0 For Each bar In Application.CommandBars bar.Enabled = True Next End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "mikegospo" wrote in message ... I asked a question earlier about restoring my command menu. I got it to work. I am using this program. I know want to make it just leave a print icon of some type. Here is the code I am using Private Sub Workbook_Activate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = False Next End Sub Private Sub Workbook_Deactivate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = True Next End Sub I guess I need one in between to add the print menu. Mike ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
see code inline:
-- Regards, Tom Ogilvy Private Sub Workbook_Activate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = False Next On Error Resume Next Commandbars("PrintBar").Delete On Error goto 0 Application.CommandBars.Add(Name:="PrintBar").Visi ble = True Application.CommandBars("PrintBar").Controls.Add _ Type:=msoControlButton, ID:=4, Befo=1 End Sub Private Sub Workbook_Deactivate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = True Next On Error Resume Next Commandbars("PrintBar").Delete On Error goto 0 End Sub -- Regards, Tom Ogilvy ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
Didnt work Tom, this is what I put in. Private Sub Workbook_Activate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = False Next On Error Resume Next CommandBars("PrintBar").Delete On Error GoTo 0 Application.CommandBars.Add(Name:="PrintBar").Visi ble = True Application.CommandBars("PrintBar").Controls.Add _ Type:=msoControlButton, ID:=4, Befo=1 End Sub Private Sub Workbook_Deactivate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = True Next On Error Resume Next CommandBars("PrintBar").Delete On Error GoTo 0 End Sub It hangs on the last CommandBars command CommandBars("PrintBar").Delete ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
Add Application before the Commandbars. Worked for me.
Private Sub Workbook_Activate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = False Next On Error Resume Next Application.CommandBars("PrintBar").Delete On Error GoTo 0 Application.CommandBars.Add(Name:="PrintBar").Visi ble = True Application.CommandBars("PrintBar").Controls.Add _ Type:=msoControlButton, ID:=4, Befo=1 End Sub Private Sub Workbook_Deactivate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = True Next On Error Resume Next Application.CommandBars("PrintBar").Delete On Error GoTo 0 End Sub -- Regards, Tom Ogilvy "mikegospo" wrote in message ... Didnt work Tom, this is what I put in. Private Sub Workbook_Activate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = False Next On Error Resume Next CommandBars("PrintBar").Delete On Error GoTo 0 Application.CommandBars.Add(Name:="PrintBar").Visi ble = True Application.CommandBars("PrintBar").Controls.Add _ Type:=msoControlButton, ID:=4, Befo=1 End Sub Private Sub Workbook_Deactivate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = True Next On Error Resume Next CommandBars("PrintBar").Delete On Error GoTo 0 End Sub It hangs on the last CommandBars command CommandBars("PrintBar").Delete ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
Now it hangs where I have the asterisk? Private Sub Workbook_Activate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = False Next On Error Resume Next **Application.CommandBars("PrintBar").Delete On Error GoTo 0 Application.CommandBars.Add(Name:="PrintBar").Visi ble = True Application.CommandBars("PrintBar").Controls.Add _ Type:=msoControlButton, ID:=4, Befo=1 End Sub Private Sub Workbook_Deactivate() Dim bar As CommandBar For Each bar In Application.CommandBars bar.Enabled = True Next On Error Resume Next Application.CommandBars("PrintBar").Delete On Error GoTo 0 End Sub End Sub ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
I get a VB error and it stops on that line. Sorry to keep bothering you but now my excel is messed up and I lost all tool bars and cant get them restored. Sorry I feel like a boob. Mike ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
add a print key only
Do you have Break on unhandled errors selected in VBA in the tools menu
under the options, then under the General Tab? If you have Break on all errors, that is your problem. -- Regards, Tom Ogilvy "mikegospo" wrote in message ... I get a VB error and it stops on that line. Sorry to keep bothering you but now my excel is messed up and I lost all tool bars and cant get them restored. Sorry I feel like a boob. Mike ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Print and Print Preview Graphic Moving Resizing 2007/2003 | Excel Discussion (Misc queries) | |||
How to format the extension less file to print with Dos's Print Command | Excel Discussion (Misc queries) | |||
cell borders that I create dont show on print preview or print | Excel Discussion (Misc queries) | |||
Pivot Table macro to set print area and print details of drill down data | Excel Discussion (Misc queries) | |||
Active cell counting in particular print page (one sheet having different print area) | Excel Worksheet Functions |