![]() |
Why "User-defined type not defined"
I got the following lines in my macro:
Dim VBCodeMod As CodeModule Dim LineNum As Long ActiveWorkbook.VBProject.VBComponents.Add vbext_ct_StdModule Set VBCodeMod = Application.VBE.CodePanes(1).CodeModule I think I copied those lines from the Pearson site. When I run the macro from my personal.xls file, the macro runs without any problem. However, when I copy the macro to a new file in the document folder, the line "VBCodeMod As CodeModule" is highlighted and this error msg appears: Compile error: User-defined typ not defined Can someone please tell me what this error is? And why this error since the macro runs problem free from the personal.xls? TIA. |
Why "User-defined type not defined"
Hi Shatin,
the line "VBCodeMod As CodeModule" is highlighted and this error msg appears: Compile error: User-defined typ not defined Can someone please tell me what this error is? And why this error since the macro runs problem free from the personal.xls? You need a reference to the VBE Extensibilty library (Tools, References from within the VBE) Regards, Jan Karel Pieterse Excel MVP www.jkp-ads.com |
Why "User-defined type not defined"
Hello Shatin
Add a reference to Microsoft Visual Basic 6.0 Extensibility HTH Regards Pascal "Shatin" a écrit dans le message de om... I got the following lines in my macro: Dim VBCodeMod As CodeModule Dim LineNum As Long ActiveWorkbook.VBProject.VBComponents.Add vbext_ct_StdModule Set VBCodeMod = Application.VBE.CodePanes(1).CodeModule I think I copied those lines from the Pearson site. When I run the macro from my personal.xls file, the macro runs without any problem. However, when I copy the macro to a new file in the document folder, the line "VBCodeMod As CodeModule" is highlighted and this error msg appears: Compile error: User-defined typ not defined Can someone please tell me what this error is? And why this error since the macro runs problem free from the personal.xls? TIA. |
Why "User-defined type not defined"
Shatin,
The reference to set is called Microsoft Visual Basic for Applications Extensibility n.n where n.n is a version number. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Shatin" wrote in message om... I got the following lines in my macro: Dim VBCodeMod As CodeModule Dim LineNum As Long ActiveWorkbook.VBProject.VBComponents.Add vbext_ct_StdModule Set VBCodeMod = Application.VBE.CodePanes(1).CodeModule I think I copied those lines from the Pearson site. When I run the macro from my personal.xls file, the macro runs without any problem. However, when I copy the macro to a new file in the document folder, the line "VBCodeMod As CodeModule" is highlighted and this error msg appears: Compile error: User-defined typ not defined Can someone please tell me what this error is? And why this error since the macro runs problem free from the personal.xls? TIA. |
Why "User-defined type not defined"
Problem solved! Thanks to you all for your help!
|
All times are GMT +1. The time now is 08:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com