Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default 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   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete all macros if workbook is saved with another name Danny Excel Worksheet Functions 4 March 16th 07 09:57 PM
How to Delete a Range in Closed Workbook (to Replace Delete Query) [email protected] Excel Discussion (Misc queries) 1 March 8th 06 10:10 AM
How to Delete Another WorkBook Macros using Macros.. Possible? ddiicc Excel Programming 7 July 24th 05 01:54 PM
How to delete macros Jaime Stuardo Excel Discussion (Misc queries) 2 February 14th 05 02:29 PM
Open workbook-macros enabled, opening another with macros George J Excel Programming 5 September 17th 04 02:07 PM


All times are GMT +1. The time now is 11:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"