Is there a way to have a macro in one workbook dynamically generate VBA code in another workbook?
Is there a way to have a macro in one workbook dynamically generate VBA code in another workbook?
Yes. See vbacomponents in the VBE or: http://www.cpearson.com/Excel/vbe.aspx
Thanks Mr. Hobs for your quick reply!
I'm a little worried about this warning "CAUTION: Many VBA-based computer viruses propagate themselves by creating and/or modifying VBA code. Therefore, many virus scanners may automatically and without warning or confirmation delete modules that reference the VBProject object, causing a permanent and irretrievable loss of code. Consult the documentation for your anti-virus software for details. ". How do you avoid accidently writing code that will be deleted and where in your antivirus documentation would this be found?
I guess it would be documented in your AV software. Contact the vendor if you need to know. If you backup your file, I don't see an issue.
I would not recommend vbacomponent methods just like SendKey() methods.
An add-in method is usually a better solution for some.
Great. Thanks again Kenneth.
Just out of curiosity..... why do you need to dynamically create code in another workbook? This is one of the things that antivirus software are designed to find and delete.
Remember To Do the Following....
Use [Code].... [/Code] tags when posting code to the thread.
Mark your thread as Solved if satisfied by using the Thread Tools options.
If posting the same issue to another forum please show the link
I want one "template creating" workbook to generate other "template" workbooks that can do specific calculations without having to repeat code in those template workbooks. I know there's probably other way to do this, but it was the first thing that came to mind, when I was trying to solve this problem.... Plus I thought it would be an interesting question for the forum.