Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Delete Another WorkBook Macros
I will stated my examples clearly, so you could help me or give me the words
to fill in the blanks. "Workbook A" name is "HSA template 1" "Workbook B" name is "HSA template 2" Workbook A contains a module name "AllDataYieldCrunch" Workbook B conains a 2 module name, 1st is "SortData", 2nd is "CrunchData" So in my workbook A, I want to add the code, macro or scripts, inside my module "AllDataYieldCrunch" together. Then it will also delete the 2 modules in workbook B. Workbook A module stated below :- Sub ########() ####$##^^%&^ #$#%^$^&*(&& }#%^%$%&*^(& ActiveWorkbook.SaveAs Filename:="E:\HSA Template 2", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False End Sub. So where should I place the script?? before the end sub?? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Delete Another WorkBook Macros
Hi,
you can try the folloowing code placing it in any place of any module of Workbook A: Sub Remove_Modules() With Workbooks("HSA template 2.xls").VBProject .VBComponents.Remove .VBComponents("SortData") .VBComponents.Remove .VBComponents("CrunchData") End With End Sub Regards, KL "ddiicc" wrote in message ... I will stated my examples clearly, so you could help me or give me the words to fill in the blanks. "Workbook A" name is "HSA template 1" "Workbook B" name is "HSA template 2" Workbook A contains a module name "AllDataYieldCrunch" Workbook B conains a 2 module name, 1st is "SortData", 2nd is "CrunchData" So in my workbook A, I want to add the code, macro or scripts, inside my module "AllDataYieldCrunch" together. Then it will also delete the 2 modules in workbook B. Workbook A module stated below :- Sub ########() ####$##^^%&^ #$#%^$^&*(&& }#%^%$%&*^(& ActiveWorkbook.SaveAs Filename:="E:\HSA Template 2", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False End Sub. So where should I place the script?? before the end sub?? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Delete Another WorkBook Macros
Hi again,
The code below does for me what you describe. You may need to go to the VBA Editor's menu ToolsReferences and set a reference to 'Microsoft Visual Basic for Application Extensibility #.#' library. Regards, KL Sub Remove_Modules() Dim arrMod As Variant Dim prOld As VBIDE.VBProject Dim mdNew As VBIDE.CodeModule Set mdNew = Workbooks("HSA template 1.xls").VBProject. _ VBComponents("AllDataYieldCrunch").CodeModule Set prOld = Workbooks("HSA template 2.xls").VBProject arrMod = Array("SortData", "CrunchData") mdNew.InsertLines mdNew.CountOfLines + 1, Chr(13) For i = LBound(arrMod) To UBound(arrMod) With prOld.VBComponents(arrMod(i)).CodeModule COL = .CountOfLines For j = 1 To COL mdNew.InsertLines mdNew.CountOfLines + 1, .Lines(j, 1) Next j mdNew.InsertLines mdNew.CountOfLines + 1, Chr(13) prOld.VBComponents.Remove prOld.VBComponents(arrMod(i)) End With Next i End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Delete Another WorkBook Macros
Hi Ddiicc,
Assuming that you do mean to delete discrete modules and not individual subs housed in a module, see response(s) in your original thread. --- Regards, Norman "ddiicc" wrote in message ... I will stated my examples clearly, so you could help me or give me the words to fill in the blanks. "Workbook A" name is "HSA template 1" "Workbook B" name is "HSA template 2" Workbook A contains a module name "AllDataYieldCrunch" Workbook B conains a 2 module name, 1st is "SortData", 2nd is "CrunchData" So in my workbook A, I want to add the code, macro or scripts, inside my module "AllDataYieldCrunch" together. Then it will also delete the 2 modules in workbook B. Workbook A module stated below :- Sub ########() ####$##^^%&^ #$#%^$^&*(&& }#%^%$%&*^(& ActiveWorkbook.SaveAs Filename:="E:\HSA Template 2", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False End Sub. So where should I place the script?? before the end sub?? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete all macros if workbook is saved with another name | Excel Worksheet Functions | |||
How to Delete a Range in Closed Workbook (to Replace Delete Query) | Excel Discussion (Misc queries) | |||
How to Delete Another WorkBook Macros using Macros.. Possible? | Excel Programming | |||
How to delete macros | Excel Discussion (Misc queries) | |||
Open workbook-macros enabled, opening another with macros | Excel Programming |