Message 1 of 21
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can someone help me modify this code to only search active sheet please
Sub main oDoc = ThisDoc.Document Dim oSheets As Sheets Dim oSheet As Sheet Dim oGeneralNotes As GeneralNotes Dim oGeneralNote As GeneralNote Dim oSymbol As SketchedSymbol Dim oSymbols As SketchedSymbols Dim oTitleBlock As TitleBlock Dim oTextBox As TextBox Dim ooTXT2Find As String Dim oNewTXT As String 'get user input oTXT2Find = InputBox("Enter Text To Find:", "iLogic", "XXX") 'look for blank value If oTXT2Find = "" Then Return 'exit rule End If oNewTXT = InputBox("Enter Text To Replace '" & oTXT2Find _ & "' with.", "iLogic", "ZZZ") 'look for blank value If oNewTXT = "" Then Return 'exit rule End If oSheets = oDoc.Sheets For Each oSheet In oSheets 'handle errors On Error Resume Next 'look at General Notes oGeneralNotes = oSheet.DrawingNotes.GeneralNotes For Each oGeneralNote In oGeneralNotes oText = oGeneralNote.FormattedText oText = ReplaceText(oText, oTXT2Find, oNewTXT) oGeneralNote.FormattedText = oText Next 'look at leader notes oLeaderNotes = oSheet.DrawingNotes.LeaderNotes For Each oLeaderNote In oLeaderNotes oText = oLeaderNote.FormattedText oText = ReplaceText(oText, oTXT2Find, oNewTXT) oLeaderNote.FormattedText = oText Next 'look at title blocks oTitleBlock = oSheet.TitleBlock For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes oText = oTitleBlock.GetResultText(oTextBox) oText = ReplaceText(oText, oTXT2Find, oNewTXT) oTitleBlock.SetPromptResultText(oTextBox, oText) Next 'look at sketched symbols oSymbols = oSheet.SketchedSymbols For Each oSymbol In oSymbols For Each oTextBox In oSymbol.Definition.Sketch.TextBoxes oText = oSymbol.GetResultText(oTextBox) oText = ReplaceText(oText, oTXT2Find, oNewTXT) oSymbol.SetPromptResultText(oTextBox, oText) Next Next Next End Sub Function ReplaceText(oText As String, oTXT2Find As String, oNewTXT As String) If oText = oTXT2Find Or oText.Contains(oTXT2Find) Then oText = Replace(oText, oTXT2Find, oNewTXT) End If Return oText End Function
Solved! Go to Solution.