#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default ctrl-p

I use this code to test for workbook name and run the appropriate print
routine.

How can I call the regular Excel ctrl-p for workbooks that are not part of
my project instead of just a beep at the end?

Sub ProjectPrint()
'
' Keyboard Shortcut: Ctrl+p
Dim FileName As String, Length As Integer, FileClass As String
On Error GoTo EndIt
FileName = ActiveWorkbook.name
Length = Len(FileName)
FileClass = Left(FileName, Length - 4)
Length = Len(FileClass)
FileClass = Right(FileClass, Length - 4)
ProcName = "Do" + FileClass + "Print"
Run ProcName
End

EndIt:
Beep
End Sub

TIA, Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ctrl-p

I'd just use a different shortcut key:
ctrl-shift-p (ctrl-P) for your code.

Without knowing how you determine if a workbook is part of your project, maybe
you could go by name:

Select case lcase(activeworkbook.name)
case is = "book1.xls", "book99.xls"
'do your macro
case else
activewindow.selectedsheets.printout 'preview:=true 'for testing??
end select

(untested, uncompiled.)

JBoulton wrote:

I use this code to test for workbook name and run the appropriate print
routine.

How can I call the regular Excel ctrl-p for workbooks that are not part of
my project instead of just a beep at the end?

Sub ProjectPrint()
'
' Keyboard Shortcut: Ctrl+p
Dim FileName As String, Length As Integer, FileClass As String
On Error GoTo EndIt
FileName = ActiveWorkbook.name
Length = Len(FileName)
FileClass = Left(FileName, Length - 4)
Length = Len(FileClass)
FileClass = Right(FileClass, Length - 4)
ProcName = "Do" + FileClass + "Print"
Run ProcName
End

EndIt:
Beep
End Sub

TIA, Jim


--

Dave Peterson
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
Is there a difference between CTRL+D and CTRL+" (quotation marks) AKMMS Excel Discussion (Misc queries) 2 March 22nd 10 07:43 PM
How to make Ctrl-C, ctrl-V work in Office 2007 hj Excel Discussion (Misc queries) 1 June 23rd 09 01:09 PM
Excel 2007: Ctrl+PgUp or Ctrl+PgDn with Protected Sheets DrDave Excel Discussion (Misc queries) 1 July 28th 08 04:12 AM
Redefining the Ctrl [ and Ctrl ]s short cut with OnKey? John Wirt[_5_] Excel Programming 6 January 24th 05 05:46 AM
Disabling Ctrl-PgUp and Ctrl-PgDn K.A. Hueston Excel Programming 3 October 9th 04 12:31 AM


All times are GMT +1. The time now is 07:22 PM.

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

About Us

"It's about Microsoft Excel"