Replacing placeholder text in a .docx
file
- Linx Designer 6.4.3 or higher
- Download this repo
- Open the
PopulatePlaceholders.solution
file in theLinx6
folder - Debug the function entitled
Main
- Enter the path to the
documents
folder of this repo into the parameter entitledDocumentsFolder
- Start the debugger
- The file
Template.docx
in thedocuments
folder will be processed and the texttodays_date
will be replaced by Linx with the current date - A new file will be created in a folder called
Results
- The original file will be moved to a folder entitled
Processed
- Add your own placeholder text to the List entitled
ListOfChanges
in theMain
function - Place any
.docx
files you want processed into theDocumentsFolder
folder - Debug the
Main
function. Alldocx
files in theDocumentsFolder
folder will be processed
- Reads the
DocumentsFolder
and returns a list of alldocx
files contained therein. - Creates the folders needed to store new and processed documents.
- Loops through the list of files and calls a function called
ReplaceDocumentWords
for each one.
- Extracts the files contained in each
docx
archive into a temporary folder. - Reads the XML file containing the text of the Word Document.
- Loops through the key-value pairs contained in the
PlaceholderAndValue
list, finds all words matching the value in the placeholder property and replaces them with the value from theValue
property. - Zips the updated files into a new '.docx' file.
- Saves the new file in the
Results
folder. - Moves the processed file to the
Processed
folder.
For questions please ask the Linx community or use the Slack channel.