View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How to add a public subroutine to a class module

You can't assign keys to methods of a class -- you can only
assign keys to regular VBA subs. Therefore, you'd have to write a
regular sub to call the method of your class:

Sub AAA()
If MyObj Is Nothing Then
Set MyObj = New MyClass
End If
MyObj.ShiftRight
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"keithb" wrote in message
...
I have an add-in containing a class module that is used by a
large group of different spreadsheets. How can I add the
following subroutine to the clas module in a way that it can be
called by the individual spreadsheets using a keypress?

Public Sub shiftRight()
With Selection
.InsertIndent -1
End With
End Sub

Thanks,

Keith