Consulting

Results 1 to 5 of 5

Thread: Remove Macros from a workbook with VBA

  1. #1

    Remove Macros from a workbook with VBA

    Hello All,

    I have a master file that I use to generate an Excel based user form. The master document has several macros in it that do not need to be in the user form. I generate the form by saving the file as a different name, but all the macros transfer to the user form. One macro in particular is in the workbook open sub, so it runs when the workbook is open.

    I need to be able to disable that one line in the workbook open sub (I have antoher line of code in there that creates a custom toolbar) .

    Thanks in advance

    Ross

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If you know the line number of the ofending line, you can remove it with

    ThisWorkbook.VBProject.VBComponents("ThisWorkbook").codemodule.DeleteLines 5, 1
    where 5 is the line number

  3. #3
    Not only did that work, but you guessed the right line to delete.

    Thanks!!!!!!!!!!

    Ross

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by rsilberfarb
    Not only did that work, but you guessed the right line to delete.
    You must write the same code as me

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by rsilberfarb
    Not only did that work, but you guessed the right line to delete.
    I think xld reads minds.

Posting Permissions

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