View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
George B[_2_] George B[_2_] is offline
external usenet poster
 
Posts: 16
Default Use of CallByName()

Thanks, Dave - that works beautifully. Much appreciated.

George B.

"Dave Peterson" wrote in message
...
I'd drop the callbyname attempt and use application.run

Option Explicit
Sub testme()
Dim SubNames As Variant
Dim i As Long
SubNames = Array("Sub1", "Sub2", "Sub3")
For i = LBound(SubNames) To UBound(SubNames)
Application.Run "'" & ThisWorkbook.Name & "'!" & SubNames(i)
Next i
End Sub
Sub sub1()
MsgBox "sub1"
End Sub
Sub sub2()
MsgBox "sub2"
End Sub
Sub sub3()
MsgBox "sub3"
End Sub


George B wrote:

Thanks for your reply, but it doesn't seem to help me. In your example,

the
object is a textbox. What I need to know is how to do the following:

Replace:
Call Sub1
Call Sub2
Call Sub3

By:
subnames=array("Sub1","Sub2","Sub3")
For i=0 to 2
Call someobject,subnames(i),vbMethod
Next i

I don't know how to specify someobject.

"Joel" wrote in message
...
The code below works in 2003 in a module. I took the help example in

VBA
and
made a minor change. I also added a textbox to the active worksheet.

See
if
this helps.


Set Text1 = ActiveSheet.OLEObjects("Textbox1").Object
CallByName Text1, "MousePointer", VbLet, vbCrosshair
Result = CallByName(Text1, "MousePointer", VbGet)

"George B" wrote:

All the references I have found on this procedure appear to be for

use
in a
class module. I would like to use it to call a procedure in

Module1.
Is
this possible? What is the object to be specified in
CallByName object,procname,calltype,[args()]




--

Dave Peterson