Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default How to add a public subroutine to a class module

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default How to add a public subroutine to a class module

I am not really following... Classes have methods which operate on objects
(which are instances of the class). Why not just add a module and place your
sub in that module. The code you posted does not make me think you are trying
to operate on the object you are creating.
--
HTH...

Jim Thomlinson


"keithb" wrote:

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



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
CLASS MODULE & SIMPLE MODULE FARAZ QURESHI Excel Discussion (Misc queries) 1 September 7th 07 09:32 AM
Calling a Public Subroutine in a Different Workbook Raul Excel Programming 2 August 24th 05 04:27 AM
Subroutine question and public variables musictech Excel Programming 1 July 1st 05 09:29 PM
Public subroutine called from a private sub Neil Bhandar[_2_] Excel Programming 1 January 15th 04 10:23 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 12:20 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"