View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Executing macro in one book from another.

Norman,
That works great. Now, I'd like to make the book that code will be
delete from dynamic based on the value of a combobox in a userform.
I've tried some subsitituions in the code but can't make it work. Any
ideas?

thanks again.
Norman Jones wrote:
Hi Michael,

I'm attempting to adapt Chip Pearson's code for deleting all code in a
workbook to run from a different workbook.

I've tried adding "With Workbooks("Book1") before the code in Book2,
but that still deletes all the code in Book2. Here is the code that I
started with:


Try replacing

Set VBComps = ActiveWorkbook.VBProject.VBComponents


with

Set VBComps = Workbooks("Book2"). _
VBProject.VBComponents

or

Set VBComps = Workbooks("Book2.xls"). _
VBProject.VBComponents

if the workbook has been saved


---
Regards,
Norman