Discussion Locked

VBA-excel access components of a project

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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

2 replies

by vivek.madani

I am not sure how this is done in VBA, but in VB/any .Net language you will have to include the reference of the "other" project (probably a dll I assume).

This discussion is closed to new replies.