Replacing placeholder text in a .docx file
- Linx Designer 6.4.3 or higher
- Download this repo
- Open the
PopulatePlaceholders.solutionfile in theLinx6folder - Debug the function entitled
Main - Enter the path to the
documentsfolder of this repo into the parameter entitledDocumentsFolder - Start the debugger
- The file
Template.docxin thedocumentsfolder will be processed and the texttodays_datewill 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
ListOfChangesin theMainfunction - Place any
.docxfiles you want processed into theDocumentsFolderfolder - Debug the
Mainfunction. Alldocxfiles in theDocumentsFolderfolder will be processed
- Reads the
DocumentsFolderand returns a list of alldocxfiles contained therein. - Creates the folders needed to store new and processed documents.
- Loops through the list of files and calls a function called
ReplaceDocumentWordsfor each one.
- Extracts the files contained in each
docxarchive into a temporary folder. - Reads the XML file containing the text of the Word Document.
- Loops through the key-value pairs contained in the
PlaceholderAndValuelist, finds all words matching the value in the placeholder property and replaces them with the value from theValueproperty. - Zips the updated files into a new '.docx' file.
- Saves the new file in the
Resultsfolder. - Moves the processed file to the
Processedfolder.
For questions please ask the Linx community or use the Slack channel.