|
-
Jan 21st, 2009, 02:10 PM
#1
Thread Starter
New Member
Calling methods of .ocx controls at runtime
Hi,
I wanted to load the .ocx controls at runtime and call its methods during runtime.
I was able to load the control at runtime but not able to set its methods and subroutines.
Here is the code snippet:
Dim WithEvents objEcg As VBControlExtender
Private Sub Form_Load()
Set obj = Controls.Add("ProgID.OCXCtrl", "ocx1", Frame1)
obj.Visible = True
obj.WebURL = "URLPath"
obj.Height = 375
obj.Left = 120
obj.Top = 240
obj.Width = 300
Call obj.methodOnOCX("strparam1", "strparam2")
End Sub
Note: methodOnOCX is a subroutine with signature as methodOnOCX(str1 as String,str2 as String)
Error on calling the function is: "Object variable or with block variable not set"
Note: I am able to set all the properties of the control and view them during runtime.
Any help is appreciated.
Thanks
-
Jan 25th, 2009, 07:13 PM
#2
Re: Calling methods of .ocx controls at runtime
Is methodOnOCX a Public method? Private & Friend declarations should fail. Additionally, if it is public, are you sure the error is coming from that call or could the error be coming from within the OCX? That may be a possibility.
-
Jan 26th, 2009, 09:11 AM
#3
Thread Starter
New Member
Re: Calling methods of .ocx controls at runtime
No, the method is a public method. If the ocx control is added during runtime itself, the method runs fine. So, I don't think there is any error in the method.
-
Jan 26th, 2009, 01:14 PM
#4
Re: Calling methods of .ocx controls at runtime
Sorry it took a bit. I think this might work. precede your methods with the word Object, like so....
Call obj.Object.methodOnOCX("strparam1", "strparam2")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|