Re : Excel To Call Sub and Assign Arguments

  • Thread starter Thread starter tkt_tang
  • Start date Start date
T

tkt_tang

Please examine the following statement,

Application.OnTime Now + TimeValue("00:00:01"), "CentrAcroSelection"

How could any arguments (as required) be assigned accordingly ?

Please share your experience.

Regards.
 
Stringtime = "00:00:01"
STime = TimeValue(Stringtime)
MyProcedure = "CentrAcroSelection"
Application.OnTime Now + STime, MyProcedure
 
Joel, Esq.,

Thank you for responding to the query.

Would like to have called the Sub as if bearing the effects of,

Call CentrAcroSelection(TitleWrap)

Needless to say, TitleWrap is an argument to be processed by the Sub,
CentrAcroSelection.

However, the syntax of OnTime method (shown above) prevents the
assignment of TitleWrap to CentrAcroSelection as it is.

Please extend a helping hand.

Regards.
 
Use a public variable to pass the parameter

Public MyParameter As String
Sub test()
MyParameter = "abc"
Application.OnTime Now + TimeValue("00:00:5"), "my_Procedure"

End Sub

Sub my_Procedure()

MsgBox (MyParameter)

End Sub
 
Joel, Esq.,

Thank you again.

"Use a Public Variable" ; that's a viable means indeed.

There appears to be no alternative means (good try aside, but in vain)
to daisy-chain arguments to the following statement,

Application.OnTime Now + TimeValue("00:00:5"), "my_Procedure" & <Daisy-
Chain of Arguments>

Regards.
 
You can make the public variable an array like

Public arg(5) as Variant

Sub Main()

arg(0) = "Hello"
arg(1) = "World"
arg(2) = "Goodbye"
arg(3) = "Joel"
arg(4) = 123
Application.OnTime Now + TimeValue("00:00:5"), "my_Procedure"

End Sub

Sub my_Procedure()

'enter yor code here

End Sub


The above example is very similar to the way Unix, and C language pass
parameters except instead of make the vaiable Publid the variable are pushed
onto a calling stack.
 

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

Back
Top