Consulting

Results 1 to 8 of 8

Thread: Dynamic VBA Generation

  1. #1

    Dynamic VBA Generation

    Is there a way to have a macro in one workbook dynamically generate VBA code in another workbook?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Yes. See vbacomponents in the VBE or: http://www.cpearson.com/Excel/vbe.aspx

  3. #3
    Thanks Mr. Hobs for your quick reply!

  4. #4
    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?

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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.

  6. #6
    Great. Thanks again Kenneth.

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,089
    Location
    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

  8. #8
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •