Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
I'm wondering if it is possible to have a macro that would delete all macros from the "ThisWorkbook" section when the workbook is saved? The reason I ask is because I have a macro within the "ThisWorkbook" section that does a few things automatically when the workbook is opened. However, before the populated workbook is saved some of the worksheets that are referenced in that opening macro are no longer there so the next time the spreadsheet is opened I now get errors. A long winded explaination but I just wanted to know if it was possible to do it. Thanks in advance. Rob |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Check out Chip Pearson's site:
http://cpearson.com/excel/vbe.htm He shows how to write code that modifies code. An alternative would be to check for a worksheet that's already gone. If it's not there, you know not to continue with the rest of the code. Option Explicit Sub Workbook_Open() dim testWks as worksheet set testwks = nothing on error resume next set testwks = me.worksheets("sheetthatsdeleted") on error goto 0 if testwks is nothing then 'it's already gone exit sub end if 'reset of code here End Sub Rob wrote: Hi, I'm wondering if it is possible to have a macro that would delete all macros from the "ThisWorkbook" section when the workbook is saved? The reason I ask is because I have a macro within the "ThisWorkbook" section that does a few things automatically when the workbook is opened. However, before the populated workbook is saved some of the worksheets that are referenced in that opening macro are no longer there so the next time the spreadsheet is opened I now get errors. A long winded explaination but I just wanted to know if it was possible to do it. Thanks in advance. Rob -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
remove macro | New Users to Excel | |||
Macro to remove text | Excel Discussion (Misc queries) | |||
Function to remove a space from text in cell WITHOUT macro?? | Excel Worksheet Functions | |||
Macro or Formula to remove Text from Cells | Excel Worksheet Functions | |||
How do I change macro text with another macro? | Excel Discussion (Misc queries) |