Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print and Print Preview Graphic Moving Resizing 2007/2003 Adam Rayburn Excel Discussion (Misc queries) 0 April 4th 07 04:18 PM
How to format the extension less file to print with Dos's Print Command Badshah Excel Discussion (Misc queries) 0 November 28th 06 12:44 PM
cell borders that I create dont show on print preview or print scott3435 Excel Discussion (Misc queries) 2 April 6th 06 02:37 AM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Active cell counting in particular print page (one sheet having different print area) ananthmca2004 Excel Worksheet Functions 1 November 24th 05 11:29 AM


All times are GMT +1. The time now is 08:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"