ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Ability to Right Click to print (https://www.excelbanter.com/excel-discussion-misc-queries/123328-ability-right-click-print.html)

asg2307

Ability to Right Click to print
 
Is there a way to add print as a selection on the "right click" menu. I
would like to highlight cell fields then right click allowing me to print and
select selection after that.

Thanks.

Dave Peterson

Ability to Right Click to print
 
You can modify that rightclick popup in code.

If you want this functionality available for every workbook you open, you can
put the code into a workbook that opens each time excel opens.

Most people would use a file by the name of personal.xls and store it in their
XLStart folder.

If you only want it to work on a specific workbook, you can put the code in that
workbook.

This is what the code could look like:

Option Explicit
Sub auto_open()
With Application.CommandBars("cell")
On Error Resume Next
.Controls("Print Selection").Delete
On Error GoTo 0

With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "Print Selection"
.OnAction = "'" & ThisWorkbook.Name & "'!PrintMySelection"
End With
End With
End Sub
Sub auto_close()
With Application.CommandBars("cell")
On Error Resume Next
.Controls("Print Selection").Delete
On Error GoTo 0
End With
End Sub
Sub PrintMySelection()
If Selection.Cells.Count = 1 Then
Beep 'why print one cell?
Else
'save paper while testing
Selection.PrintOut preview:=True
End If
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

This code goes in a general module in either case (personal.xls or the specific
workbook).

==
In fact, you can limit this to just a single worksheet if you want.

asg2307 wrote:

Is there a way to add print as a selection on the "right click" menu. I
would like to highlight cell fields then right click allowing me to print and
select selection after that.

Thanks.


--

Dave Peterson

asg2307

Ability to Right Click to print
 
Thanks this helps greatly.

"Dave Peterson" wrote:

You can modify that rightclick popup in code.

If you want this functionality available for every workbook you open, you can
put the code into a workbook that opens each time excel opens.

Most people would use a file by the name of personal.xls and store it in their
XLStart folder.

If you only want it to work on a specific workbook, you can put the code in that
workbook.

This is what the code could look like:

Option Explicit
Sub auto_open()
With Application.CommandBars("cell")
On Error Resume Next
.Controls("Print Selection").Delete
On Error GoTo 0

With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "Print Selection"
.OnAction = "'" & ThisWorkbook.Name & "'!PrintMySelection"
End With
End With
End Sub
Sub auto_close()
With Application.CommandBars("cell")
On Error Resume Next
.Controls("Print Selection").Delete
On Error GoTo 0
End With
End Sub
Sub PrintMySelection()
If Selection.Cells.Count = 1 Then
Beep 'why print one cell?
Else
'save paper while testing
Selection.PrintOut preview:=True
End If
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

This code goes in a general module in either case (personal.xls or the specific
workbook).

==
In fact, you can limit this to just a single worksheet if you want.

asg2307 wrote:

Is there a way to add print as a selection on the "right click" menu. I
would like to highlight cell fields then right click allowing me to print and
select selection after that.

Thanks.


--

Dave Peterson



All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com