VBA-excel access components of a project - TechRepublic
General discussion
September 30, 2004 at 09:08 PM
apoorva.srivastava

VBA-excel access components of a project

by apoorva.srivastava . Updated 21 years, 9 months ago

How to access component of a project from another project?

When the object of another 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”).VBProject.VBComponents

If obj.Name = “frmFlatDiscount” Then

obj.Designer.Controls.Item(“txtDiscount”).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.

Thanks & Regards,

Apoorva Srivastava

This discussion is locked

All Comments