![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Hi again,
I have a macro which I want to run one time, then delete it with code. I was thinking have 2 macros, then when the one i want to delete runs, at the end ill add "Call deletemacro" which will call the 2nd macro to delete the first. Does anyone have the code to delete a module of code from within vb? Thanks |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Hi al,
Thanks for the link, i added the reference and tried this code: Sub Delete_Save() Dim VBComp As VBComponent Set VBComp = ThisWorkbook.VBProject.VBComponents("SaveMacro") ThisWorkbook.VBProject.VBComponents.Remove VBComp End Sub but im getting the error "Programmic access to Visual Basic Project is not trusted". is there a way to get around this? thanks |
|
|
|
|
|
#4 |
|
.
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
|
Yes. In tools > Macro > security, you can change this. Go to Trusted Sources tab and check the box for Trust Access to Visual Basic Project.
__________________
Preview my latest book for Free |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|