ctrl-p

G

Guest

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
 
D

Dave Peterson

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top