LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Possible to do a search/replace in the IDE Code window with VB

Some questions for you, Bernie:

1. In ReplaceCodeInModule, after you delete the original lines N of code,
isn't it illegal to insert at N+1?

2. Are you familiar with the Find method's "patternsearch" parameter, i.e.,
the regular-expression syntax it uses? I saw that someone posted this link
for the syntax, but that page is entitled 'JScript / Regular Expression
Syntax (Scripting)".

http://msdn.microsoft.com/library/de...6f58358c0e.asp

--
Andy Smith
Senior Systems Analyst
Standard & Poor''s, NYC



"Bernie Deitrick" wrote:

The code below requires a reference to MS VBA Extensibility (whichever version you have). This
does a global replace, so be careful that you are replacing a unique string...

HTH,
Bernie
MS Excel MVP

Sub ReplaceCodeInModule()
Dim myCode As String
Dim WhatToFind As String
Dim ReplaceWith As String
Dim modName As String
Dim myBook As Workbook

WhatToFind = "Hello"
ReplaceWith = "Hello World"
modName = "Module1"

Set myBook = ActiveWorkbook

With myBook.VBProject.VBComponents.Item(modName).CodeMo dule
myCode = .Lines(1, .CountOfLines)
myCode = Replace(myCode, WhatToFind, ReplaceWith)
.DeleteLines 1, .CountOfLines
.InsertLines .CountOfLines + 1, myCode
End With

End Sub

wrote in message
...
2003/ 2007

Is it possible, using VBA, to do a search/replace in another VBA module's IDE Code window with
VBA?

If so, What objects are involved? Is there a link explaining the process?

TIA EagleOne




 
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
VBA line of code executes in Immediate Window but not in Code Window [email protected] Excel Discussion (Misc queries) 2 April 30th 07 02:52 PM
Docking Project Explorer, Properties window and Code window in VBE jayray Setting up and Configuration of Excel 2 March 27th 07 04:42 PM
Duplicated code window and userform window problem Zhu Excel Programming 3 November 8th 06 05:09 AM
Search and replace chunks of html code method373 Excel Discussion (Misc queries) 0 March 27th 06 03:46 PM
Code to search and replace info on modules Brett Smith[_2_] Excel Programming 2 January 12th 06 08:58 PM


All times are GMT +1. The time now is 06:10 PM.

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

About Us

"It's about Microsoft Excel"