0

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)  
2
  • 1
    Could 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
    Commented Jun 15, 2023 at 9:21
  • You need to include some (minimal) example code which shows what you already tried. Commented Jun 15, 2023 at 18:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.