Thatâs what I initially did with my Replace Text activity
Replace Text
"Modification No. " - "Modification No. " + VariableIamReplacingWIth and it keeps the last part i.e. P00004 or 016 or whatever the rest of the line is so it looks like
Modification No. 5P00004
Please show me your .xaml or at least a screenshot. I think we are misunderstanding each other. There is no âreplace textâ activity being used in my answer. You shouldnât have an input text at all, and there should be no âreplace textâ activity, itâs all done in a single assign activity
I am modifying a word document that has "Modification No. and an unknown value like P00004 after it. Thatâs why I was trying to use a Replace Text activity.
I completely understand what youâre trying to do. I just donât understand why the âreplace textâ is necessary. You need to use âreplace textâ only when you are replacing substrings sporadically throughout a string. If you are just hardcoding the front and appending a new variable to the end, then you should not use âreplace textâ and should instead use "hardcode text " + YourStringVariable instead
EDIT: again, if you provide an .xaml or at least a screenshot of your workflow it may make it easier
I use Word Application Scope since I am modifying an existing word document.
I donât understand the flow youâre suggesting. If I assign myVariable= âModification No.â and then use assign for IntendedOutput= myVariable + VariableIamReplacingWith, nothing happens
The values coming out of the excel file works. I can easily add the valueIamReplacing in my xaml. My only issue is getting the unknown value i.e. P00004, 016, or whatever else coming after Modificiation No. to be removed.
My variable always starts with âModification No.â
The write line output for what you describe works.
My problem is that it does not replace the P00004. I cannot put âModification No. P00004â as the value of my variable because the P00004 will not always follow Modification Number.
myVariable= âModification No.â
Assign newVariable= myVariable.substring(0,16) output âModification No.â
Assign resultVariable= newVariable + myVariable output âModification No. 4â
The write line shows the correct output but nothing happens to my word doc, which is why I think I need a Replace Text activity but it wonât remove the P00004, or any value following the Modification No. The result when I use a replace text activity is Modification No. 4 P00004
@Jessica_Moseley - the reason we are all struggling to provide an answer is because of the way the question is worded. It is still not clear what youâre trying to do. Please provide 3 things:
An example/sample of a FULL TEXT representation of what the input may look like
An example of what you want the final output to look like
A quick explanation of what youâre trying to achieve, what youâve tried so far, what youâre struggling with, etc.
So far, youâve only provided a portion of each of these.
My apologies. I am trying to be as clear as possible. I cannot share the xaml because itâs for a client.
The bot reads an excel cell and the output is variable: modNumber (attached image shows â4â is the modNumber)
The bot opens the word document that has a different value (attached image shows âModification No. P00003â)
I want the final output to look like âModification No. 4â
So the ENTIRE TEXT of the input text is: Modification No. P00003 is that correct? Because if not, that is exactly why you are getting bad answers.
If it is the entire text, then you should do as Iâve stated before. assign Final Output = "Modification No. " + modNumber and write that to your word doc (or whatever your output format is going to be).
If itâs NOT the entire text, then we will need to get a better sample of what the input text will look like. At the very least, we need to know if this is in the middle of the doc, or only at the front, if you need to keep whatever is before/after this text, etc. The more info the betterâŚ
The ENTIRE TEXT of the input is a variation of Modification No. P00003 or could be Modification No. 016, etc. It will always start with Modification No. and it is in the header. Attached is what the header looks like.
Iâm confused on how to write that to my word doc, which is why I was using the Replace Text activity.
Ok, based on that picture Modification⌠is not the entire text. It is a substring within a larger amount of text in your entire word document.
Based on this new info, I think your best bet is to use regex. First step is to read the entire word document (iâll call it InputText).
Next, use regex to find the correct âjunkâ you want to replace. You havenât provided enough data or examples to give a 100% accurate regex, but this should be a good start for you: (?<=Modification No\.\s*)\S+\b - this regex will find the first word (any number/letter/character between 2 spaces) that occurs after âModification No.â. Save the value here to a string variable Iâll call junkString Assign junkString = System.Text.RegularExpressions.Regex.Match(InputText,"(?<=Modification No\.\s*)\S+\b").Value
Now that you know the âjunkâ to replace with your new word, you can utilize the âreplace text in documentâ activity.
Search for: "Modification No. " + junkString
Replace with: "Modification No. " + modNumber
And thatâs it! Now your word document should have the proper modNumber coming from your excel document. Be sure the âautosaveâ is checked in your word application scope so it saves everything properly
Hello Jessica,
In this video I do a lot of stuff with String:
0:35 Examples for Substring functions
4:10 IndexOf and LastIndexOf
5:00 SubString working together IndexOf and LastIndexOf
6:45 Split string by character
8:50 Split string by string
12:00 Lower Case and Upper Case
12:45 Trim
15:05 Compare strings in multiple ways
19:05 Resume of all the String function part