Userform Control Change from Different Workbook

J

J Pietsch

I would like to change a Userform Control value in a different
workbook before I load it from again, a different workbook.

WorkbookA.xla - Contains said Userform. I do not want to change
anyprogramming in this xla. I only want to reference a given userform
control therein and change its value remotely.

WorkbookB.xls - Will have the routine to change said control value,
then show the form (already know how to do the later).

This would be easy from all the same sheet. Any thoughts? Again, it
is a contstraint that I cannot change the xla... just can't figure out
how to address the object.

Thanks!
 
P

Peter T

Unusual!

AFAIK not possible to access the form in the other book until its loaded, so
you will need to add something to the other addin

' in a normal module, not headed Private in the xla
Function GetUF() As UserForm1
Set GetUF = UserForm1
End Function


' in the calling workbook
Sub test()
Dim myForm As Object

Set myForm = Application.Run("myAddin.xla!GetUF")

myForm.Controls("CommandButton1").Caption = "Hello"

myForm.Show

End Sub


If it's viable to set a reference to your addin,
Set myForm = myAddinProjectName!GetUF")

I would have thought much better to call a routine in the addin, pass
arguments for new control properties, and have that routine load the form,
do the changes and run the form. When done pass back any results to the
calling workbook.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top