Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default can I call a procedure using a variable

can I call a procedure with a variable as part of the procedure's name?

I have a whole bunch of procedures named something_somethingelse_click()

can I concatenate 2 variables and make them part of the call?

thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default can I call a procedure using a variable

Your request confuses me.

I don't know of a way to discover the procedure name that is running.
for example - this doesn't exist:
sub mytestproc()
msgbox application.current_procedure_running()
end sub

If you're asking if one procedure could handle lots of different events -I
think VB.NET handles this well. I don't know when Excel will start using
this (or if it has already in XL2003)

If none of the above fits, you could do similar to the following:

sub something_somethingelse_click()
something "somethingelse"
end sub

sub something_somethingdifferent_click()
something "somethingdifferent"
end sub

sub something(strvariable as string)
if strvariable = "somethingelse" then
msgbox "wow!"
elseif strvariable = "somethingdifferent" then
msgbox "that's a relief"
else
msgbox "no idea!"
end if
end sub



"Santiago Gomez" wrote in message
...
can I call a procedure with a variable as part of the procedure's name?

I have a whole bunch of procedures named something_somethingelse_click()

can I concatenate 2 variables and make them part of the call?

thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default can I call a procedure using a variable

Application.Run StringVar


"Santiago Gomez" wrote in message
...
can I call a procedure with a variable as part of the procedure's name?

I have a whole bunch of procedures named something_somethingelse_click()

can I concatenate 2 variables and make them part of the call?

thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default can I call a procedure using a variable

Thanks, I think this is what I need, however, I get errors when I try
running a procedure this way.
This is what I have...a simple example:

Sub ProcedureOne()
Application.Run "mysub1", "test"
End Sub

Sub mysub1(sTemp As String)
Debug.Print sTemp
End Sub

When I run this I get Error 2517, "Can't find the procedure 'mysub1.'.

I've tried, no quotes, single quotes, etc.

any ideas?


"Tim Zych" wrote in message
...
Application.Run StringVar


"Santiago Gomez" wrote in message
...
can I call a procedure with a variable as part of the procedure's name?

I have a whole bunch of procedures named

something_somethingelse_click()

can I concatenate 2 variables and make them part of the call?

thanks






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default can I call a procedure using a variable

It works for me. Do you have any syntax errors anywhere else in your
project? Add Option Explicit to every module and sheet then Debug -
Compile..


"Santiago Gomez" wrote in message
...
Thanks, I think this is what I need, however, I get errors when I try
running a procedure this way.
This is what I have...a simple example:

Sub ProcedureOne()
Application.Run "mysub1", "test"
End Sub

Sub mysub1(sTemp As String)
Debug.Print sTemp
End Sub

When I run this I get Error 2517, "Can't find the procedure 'mysub1.'.

I've tried, no quotes, single quotes, etc.

any ideas?


"Tim Zych" wrote in message
...
Application.Run StringVar


"Santiago Gomez" wrote in message
...
can I call a procedure with a variable as part of the procedure's

name?

I have a whole bunch of procedures named

something_somethingelse_click()

can I concatenate 2 variables and make them part of the call?

thanks










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default can I call a procedure using a variable

doh!, I just realized I am in the wrong application. I am using Access, not
excel.
sorry guys,
i added th option explicit but it still doesnt work.

I do get the intelli popup thingie when I type Application.Run, is this a
difference between access and excel?

thanks anyway for your help.


"Tim Zych" wrote in message
...
It works for me. Do you have any syntax errors anywhere else in your
project? Add Option Explicit to every module and sheet then Debug -
Compile..


"Santiago Gomez" wrote in message
...
Thanks, I think this is what I need, however, I get errors when I try
running a procedure this way.
This is what I have...a simple example:

Sub ProcedureOne()
Application.Run "mysub1", "test"
End Sub

Sub mysub1(sTemp As String)
Debug.Print sTemp
End Sub

When I run this I get Error 2517, "Can't find the procedure 'mysub1.'.

I've tried, no quotes, single quotes, etc.

any ideas?


"Tim Zych" wrote in message
...
Application.Run StringVar


"Santiago Gomez" wrote in message
...
can I call a procedure with a variable as part of the procedure's

name?

I have a whole bunch of procedures named

something_somethingelse_click()

can I concatenate 2 variables and make them part of the call?

thanks










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default can I call a procedure using a variable

Don't know why it's not working for you. I tried it in Access 2000 and it
worked. Does it help if you try it out in a new database? Also make sure
that mysub1 procedure is Public and not Private.


"Santiago Gomez" wrote in message
...
doh!, I just realized I am in the wrong application. I am using Access,

not
excel.
sorry guys,
i added th option explicit but it still doesnt work.

I do get the intelli popup thingie when I type Application.Run, is this a
difference between access and excel?

thanks anyway for your help.


"Tim Zych" wrote in message
...
It works for me. Do you have any syntax errors anywhere else in your
project? Add Option Explicit to every module and sheet then Debug -
Compile..


"Santiago Gomez" wrote in message
...
Thanks, I think this is what I need, however, I get errors when I try
running a procedure this way.
This is what I have...a simple example:

Sub ProcedureOne()
Application.Run "mysub1", "test"
End Sub

Sub mysub1(sTemp As String)
Debug.Print sTemp
End Sub

When I run this I get Error 2517, "Can't find the procedure

'mysub1.'.

I've tried, no quotes, single quotes, etc.

any ideas?


"Tim Zych" wrote in message
...
Application.Run StringVar


"Santiago Gomez" wrote in message
...
can I call a procedure with a variable as part of the procedure's

name?

I have a whole bunch of procedures named
something_somethingelse_click()

can I concatenate 2 variables and make them part of the call?

thanks












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
call procedure problem stan Excel Discussion (Misc queries) 2 August 17th 09 06:11 PM
to call procedure in a worksheet in a module CAPTGNVR Excel Discussion (Misc queries) 4 January 30th 07 09:39 PM
Selective call procedure jamesa Excel Programming 2 October 2nd 03 10:04 AM
call procedure bob Excel Programming 1 August 9th 03 12:40 AM
procedure won't call John Gittins Excel Programming 0 August 5th 03 08:17 PM


All times are GMT +1. The time now is 03:00 AM.

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"