Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA line of code executes in Immediate Window but not in Code Window | Excel Discussion (Misc queries) | |||
Docking Project Explorer, Properties window and Code window in VBE | Setting up and Configuration of Excel | |||
Duplicated code window and userform window problem | Excel Programming | |||
Search and replace chunks of html code | Excel Discussion (Misc queries) | |||
Code to search and replace info on modules | Excel Programming |