Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use QM's regular expression to replace text in word
#1
Microsoft's word software, the wildcard is not standardized, how to use QM regular expression function, in word: to find, and replace the text operation?

in QM software help, the find, replace of the example, are the text of the operation, the text is not format! But in the word operation can be retained format!

I think the QM code is easier to understand than the VBA code, and many people should try it Idea

I hope that QM developers can help me provide some examples, for example, how to convert the following VBA code into QM code, thank you very much Smile

I have just been in contact with programming less than two months,I think that a representative example can quickly improve the programming level Tongue


1.VBA:(Find replacement of define content)

With Selection.Find
.ClearFormatting
.Text = "hi"
.Replacement.ClearFormatting
.Replacement.Text = "hello"
.Execute Replace:=wdReplaceAll, Forward:=True, _
Wrap:=wdFindContinue
End With


2.VBA:(Find replacement of uncertain content)

For example, in the above code, find: hi123 hi4568 yshi8 and replace it with: hello


3.VBA:(Find replacement format)

With ActiveDocument.Content.Find
.ClearFormatting
.Font.Bold = True
With .Replacement
.ClearFormatting
.Font.Bold = False
End With
.Execute FindText:="", ReplaceWith:="", _
Format:=True, Replace:=wdReplaceAll
End With

4.VBA:(To manipulate specific words in the entire Microsoft Word document)

Const wdReplaceAll = 2
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Open("C:\Scripts\Test.doc")
Set objSelection = objWord.Selection
objSelection.Find.Text = "Fabrikam"
objSelection.Find.Forward = TRUE
objSelection.Find.MatchWholeWord = TRUE
objSelection.Find.Replacement.Font.Bold = True
objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)