Removing unwanted spaces in .docx files

Hello All, I have a requirement that I need to update the word document string dynamically from the UI Path. Using the word activity components, I found a way to replace the text using “Replace text” activity. However, there are some values from UI Path which are passed as NULL creates unwanted spaces in the .docx file.
For Example: While updating student information in the file, the fields like Address Line 2, phone number, Secondary Mail address can be empty which creates unnecessary spaces in the target file.
Any suggestions to handle this issue?
Thanks in advance

Hi @Melwyn_Abraham

did you already try to assign an empty string as standard value of the variable?

I do not know your project structure but you also could validate the values before you send them to the Replace activity.