Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
modifiyng code
I have a folder that contains many subfolders, each of the subfolders
contains so many excel sheets with VBA code. The excel files are similar in their structure and their code (but contain different data). The problem is that I want to add (or delete or comment) some line of code to all of the Excel sheets without opeining them one by one. Is there a method for doing this? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
modifiyng code
Marwan,
You can loop through the folders, open each file, manipulate the VBA code as needed, then close each file. Something like the following: Dim Ndx As Long Dim WB As Workbook With Application.FileSearch .NewSearch .LookIn = "C:\ExcelProjects" .SearchSubFolders = True .Filename = "*.xls" For Ndx = 1 To .Execute(msoSortByFileName) Set WB = Workbooks.Open(.FoundFiles(Ndx)) ' ' code to manipulate WB.VBProject ' WB.Close savechanges:=True Next Ndx End With In the code above, insert the specific code to delete or comment out the code inside the For loop. You can find example code that modifies code modules at www.cpearson.com/excel/vbe.htm . -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com "marwan hefnawy" wrote in message ... I have a folder that contains many subfolders, each of the subfolders contains so many excel sheets with VBA code. The excel files are similar in their structure and their code (but contain different data). The problem is that I want to add (or delete or comment) some line of code to all of the Excel sheets without opeining them one by one. Is there a method for doing this? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Code to conditional format all black after date specified in code? | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
Convert a Number Code to a Text Code | Excel Discussion (Misc queries) | |||
modifiyng code | Excel Programming |