Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
modifiyng code marwan hefnawy Excel Programming 0 August 27th 03 04:25 PM


All times are GMT +1. The time now is 03:42 AM.

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"