ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform Control Change from Different Workbook (https://www.excelbanter.com/excel-programming/434363-userform-control-change-different-workbook.html)

J Pietsch

Userform Control Change from Different Workbook
 
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!

J Pietsch

Userform Control Change from Different Workbook
 
Oh, and I'm trying to support both '03 & '07! Thanks again!

Peter T

Userform Control Change from Different Workbook
 
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


"J Pietsch" wrote in message
...
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!





All times are GMT +1. The time now is 02:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com