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
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
I have just been in contact with programming less than two months,I think that a representative example can quickly improve the programming level
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)
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
Thank you very much, you must be an office automation expert
These examples I have to think about it carefully
In addition, I would like to ask, how to use QM software replacerx function to achieve the above operation? I feel the word software to find the replacement function is too long-winded, the code is relatively long
can You use the (pointer and array and replacerx) three functions to solve the above problems? the following picture is an example, the feeling is a good idea, but I understand a bit difficult, poor programming level :oops:
First off, I'm not good at regular expression so I could not help you much on this.
Secondly I know your point about the "so-much wording" in Word and how to reduce them similar as VBA code does. Frankly speaking I have no glue how to do it, and I think that's one of the advantages of VBA code to have such keyword as "With" or "Using", etc. But I have no clue how to implement it in QM2.
Indeed, as you said, each programming language has its own advantages, I now think of a way to VBA code into VBS code, and then run the VBS code in QM, this may be a good choice, Like the following code
Thank you very much for your help and advice, best wishes
I tried QM to find the replacement function, success, QM too powerful, than Word vba lookup replacement function, much more powerful :lol:
_________________________________________
typelibWord{00020905-0000-0000-C000-000000000046}8.0 Word.Application app._getactive;;connect to Word. Note: need the /exe 1. Word.Document doc=app.ActiveDocument str s=doc.Content.Text ;out s
s.findreplace("[13]""[10]");;Word text newlines are [13] str rx= ;(?xm) ;help ARRAY(POINT) a;int i if(!findrx(s rx 04 a))end"failed, regular expression" for i 0 a.len ,VARIANT v1(a[0 i].x) v2(a[0 i].y) ,Word.Range ran=doc.Range(v1 v2) ,ran.Bold=1 ,ran.Font.Size=15
The above code is to find specific characters, but how to find a specific format? Hope that someone can help me, any suggestions and comments are welcome
I think there must be a way to solve this problem, my programming level is too poor, I hope the developer can guide me, thank you very much
These examples are very valuable, and I hope that the developer will write this example to the QM help file, and I would like the office staff to see it and improve office productivity
typelibWord{00020905-0000-0000-C000-000000000046}8.0 Word.Application app._getactive;;connect to Word. Note: need the /exe 1. Word.Document doc=app.ActiveDocument str s=doc.Content.Text ;out s
s.findreplace("[13]""[10]");;Word text newlines are [13] str rx= ;(?xm) ;help ARRAY(POINT) a;int i if(!findrx(s rx 04 a))end"failed, regular expression" for i 0 a.len ,VARIANT v1(a[0 i].x) v2(a[0 i].y) ,Word.Range ran=doc.Range(v1 v2) ,ran.Bold=1 ,ran.Font.Size=15
typelibWord{00020905-0000-0000-C000-000000000046}8.0 Word.Application app._getactive;;connect to Word. Note: need the /exe 1. Word.Document doc=app.ActiveDocument str s=doc.Content.Text ;out s
s.findreplace("[13]""[10]");;Word text newlines are [13] str rx= ;(?xm) ;help ARRAY(POINT) a;int i if(!findrx(s rx 04 a))end"failed, regular expression" for i 0 a.len ,VARIANT v1(a[0 i].x) v2(a[0 i].y) ,Word.Range ran=doc.Range(v1 v2) ,ran.Text="HELP"
Use the pointer to replace, when the replacement character is very long is unsuccessful, :oops:
typelibWord{00020905-0000-0000-C000-000000000046}8.0 Word.Application app._getactive;;connect to Word. Note: need the /exe 1. Word.Document doc=app.ActiveDocument str s=doc.Content.Text ;out s
s.findreplace("[13]""[10]");;Word text newlines are [13] str rx= ;;(?xm) ;;help ARRAY(POINT) a;int i if(!findrx(s rx 04 a))end"failed, regular expression" for i 0 a.len ,VARIANT v1(a[0 i].x) v2(a[0 i].y) ,Word.Range ran=doc.Range(v1 v2) ,ran.Find.Font.Bold=1 ,ran.Find.Replacement.Font.Bold=0