PDA

View Full Version : [SOLVED] Remove Macros from a workbook with VBA



rsilberfarb
05-19-2005, 09:46 AM
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

Bob Phillips
05-19-2005, 10:18 AM
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

rsilberfarb
05-19-2005, 01:01 PM
Not only did that work, but you guessed the right line to delete.

Thanks!!!!!!!!!!

Ross

Bob Phillips
05-19-2005, 01:14 PM
Not only did that work, but you guessed the right line to delete.

You must write the same code as me :*)

Zack Barresse
05-19-2005, 01:33 PM
Not only did that work, but you guessed the right line to delete.

I think xld reads minds. :eek: