Legacy SOLIDWORKS macro in *.swb format failed when edited with a 'Compile Error: User-defined type not defined' error. It usually runs correctly if run from the Tools->Macro->Run menu:
SWBasic macros are scripts stored in ASCII format (i.e. plain text) which cannot store any references information. SOLIDWORKS types are defined in the SOLIDWORKS type libraries which ae not referenced by default in SWBasic macros.
- Open the macro for editing (Tools->Macro->Edit)
- Navigate to the Tools->References menu
- Check all SOLIDWORKS type libraries
- Save the macro in *.swp format