How can I pass user-defined variables to xlam files?
I have written a macro and saved on an xlam file. I reference the xlam in an xlsm file and I call the macro from the xlsm. I want to pass a user-defined variable to the macro, the user-defined type being defined in the xlsm file as public. I get a "compile error: User=defined type not defined" in the xlam file.
Thanks in advance
[edit]
After several trial and error I believe I have solved the problem.
Some (shortened )code below for others to use. Hope this helps.
In the library file I declare the UDT (user defined type) and I write the macro.
Public Type chartType
chartObject As Variant
...
End Type
Public Sub formatting_chart(cht As chartType)
[code here]
End Sub
In the xlsm file I declare the variable and call the library macro as follows:
Public cht As chartType
Call lib01.formatting_chart(cht)
-
1Could you add more detail and back all of it with your code (as text) so less experienced VBA users could learn something i.e. more people could benefit from your question and any potential answers?VBasic2008– VBasic20082023年06月15日 09:21:08 +00:00Commented Jun 15, 2023 at 9:21
-
You need to include some (minimal) example code which shows what you already tried.Tim Williams– Tim Williams2023年06月15日 18:13:14 +00:00Commented Jun 15, 2023 at 18:13