apoorva_sriv
asked on
How to access the component of one project from another project(URGENT)
When the object of one project is accessed from some different project a run time error comes as follows:
“Object Variable or With block variable not set”
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Sub DisProfile()
Dim obj As VBComponent
If ActiveSheet.Name = "Discount Profile" Then
For Each obj In Workbooks("APTv3.2.xls").V BProject.V BComponent s
If obj.Name = "frmFlatDiscount" Then
obj.Designer.Controls.Item ("txtDisco unt").text = "56" ‘ Error comes here
Exit For
End If
Next
Worksheets("Discount Profile").ComboBox84.Value = Worksheets("Discount Profile").Range("A9")
End If
End Sub
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Here I am trying to set text in the textBox of the form frmFlatDiscount
“Object Variable or With block variable not set”
--------------------------
Sub DisProfile()
Dim obj As VBComponent
If ActiveSheet.Name = "Discount Profile" Then
For Each obj In Workbooks("APTv3.2.xls").V
If obj.Name = "frmFlatDiscount" Then
obj.Designer.Controls.Item
Exit For
End If
Next
Worksheets("Discount Profile").ComboBox84.Value
End If
End Sub
--------------------------
Here I am trying to set text in the textBox of the form frmFlatDiscount
ASKER
Thanks for the quick response
Now it is giving the error as "ActiveX component can't create object"
at the newly added line:
set obj = new vbcomponent ' error comes here
Now it is giving the error as "ActiveX component can't create object"
at the newly added line:
set obj = new vbcomponent ' error comes here
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dim obj as new vbcomponent
or
dim obj as vbcomponent
.
.
.
.
set obj = new vbcomponent '' before using the object obj
By saying new you are actually creating an instance of the object called vbcomponent.