MSExcel button macro pass var how?

MSExcel button macro pass var how?

Post by Tim Richardso » Wed, 28 May 1997 04:00:00



I can assign an OnAction property to a button in MSExcel.
But how can this macro know what button is calling it?
I can't work out how to pass variables, such as the button name.
Can the macro itself access something to tell it which button was
pressed?

My requirement is to to have a common button handling macro.

thanks in advance,

Tim Richardson

Please reply via email as well as news post.

 
 
 

MSExcel button macro pass var how?

Post by Kalle Schmid » Thu, 29 May 1997 04:00:00


the OnAction property is related to Excel itself ( application )
As far as I know, this event is always generated by pressing ENTER

This is not a property of a control like a button.

An there is no way to pass any parameters by this event.

Think about the CALLER property. There youl find, I suppose.
Or email your exact goal.

kalle



| I can assign an OnAction property to a button in MSExcel.
| But how can this macro know what button is calling it?
| I can't work out how to pass variables, such as the button name.
| Can the macro itself access something to tell it which button was
| pressed?
|
| My requirement is to to have a common button handling macro.
|
| thanks in advance,
|
| Tim Richardson
|
| Please reply via email as well as news post.
|

 
 
 

MSExcel button macro pass var how?

Post by John Abe » Thu, 29 May 1997 04:00:00


I copied the following out of some prototype code I wrote
in VBA for Excel 5.  It used Application.Caller to capture
the button name of the calling button.  If you name your
buttons carefully you can use the names to determine how to
handle the button.
  -John Abel-

Sub gotogroupworkbook()             'activate workbook based on button
pressed
                                                        'NEED TO HANDLE
FILE ERRORS BETTER
    On Error GoTo errorhandler      'do something if file won't open
    Dim numerror As Integer
    Application.ScreenUpdating = False
    folder = Range("folder_path").Value
    numerror = 1
    but_name = Application.Caller                      'get name of
calling button
    groupname = Right(but_name, Len(but_name) - 4)      'strip "but_"
from name
    testnum = Right(but_name, 2)                        'last 2 chars
are test number
    groupname = Left(groupname, Len(groupname) - 3)     'strip "gnn"
from groupname
    Workbooks.Open Filename:=folder & "HQ-" & groupname & ".XLS"      
'open group workbook
    Sheets("TP" & testnum).Select       'select the appropriate sheet
    Application.ScreenUpdating = True
Exit Sub

 
 
 

1. v8.2 macro question - passing the contents of a data step var iable to a macro

Andreas:

No, no, I was the one with the half-baked solution.  I was merely pointing
out that I was attempting to solve a problem one way ( half-baked because it
didn't work, mixing macro and data step ) and Puddin' Man suggested an
entirely new solution that did work.

Please understand that I'm appreciative of each suggestion / solution
provided; each one is an opportunity to broaden my knowledge of SAS.

Regards,
Harry

2. $50,000 per month - LEGAL

3. pass cmdline var to this syntax s/$var/$revar/

4. 8bitmime

5. macro var into char var

6. iVox - GoVox's OEM?

7. macro help: reference %global macro vars

8. Debugging DLLs from the Mac

9. Looking for MSExcel Macro Help for MSAccess Importation...

10. Lotus 5/Macro Button/Manipulate under macro control.

11. v8.2 macro question - passing the contents of a data step variabl e to a macro

12. Advantage of passing var types

13. &sub1(@array,$var); -> passing an array and scalar to a subroutine...