February 28, 20187 yr I'm wondering if Scribe plugin can find and replace multiple fields and how would I write that script? I've duplicated the script from the demo, but I'm unsure how to work it to replace these different fields, such as "Company Name" "Company Address" "City" "State" "Zip" etc. Any help would be greatly appreciated Edited February 28, 20187 yr by kims
March 1, 20187 yr Hi kims, Assuming you are using a Word document and a template with placeholders, the short answer is you need to call ScribeDocSubstitute for every placeholder you need to replace. I'd also recommend that you make your placeholders a bit more unique like "CompanyName", "CompanyAddress" "CompanyCity" "CompanyState" etc. I'm a bit weary if you copied the demo script verbatim because they are definitely set up to work within that file so you will need make sure that you modify any field references and any control script steps like go to record, go to layout, etc when they are not necessary. I highly recommend that you write your own script and use the demo file as an example of how to use the plugin. The basic workflow for substituting text in a Word document using Scribe are as follows: //Load the document ScribeDocLoad(Documents::myDocument) //Find and replace all placeholders. Call ScribeDocSubstitute for each ScribeDocSubstitute("CompanyName";Company::Name) ScribeDocSubstitute("CompantAddress"; Company::Address) etc. //Save the document Set Field [Documents::ScibeDocument; ScribeDocSaveContainer(newname.docx) //Alternatively you can save the document using ScribeDocSaveFile if you would rather save the file outside of your solution ScribeDocSaveFile(Get(DesktopPath)&newname.docx) Hope that helps!
March 2, 20187 yr Author Yes, I got what I needed. Guess I didn't think it through all the way before writing the post. My second question... Is there any way to have Scribe delete a line from the Word Doc? For example, if there is nothing in the CompanyAddress2 field, I don't need that in the document so it needs to be deleted out.
March 9, 20187 yr Not explicitly. I suppose you could have an if conditional that checks to see if the corresponding FileMaker field for CompanyAddress2 is empty and if it is, write an empty string ("") to the document. This probably wont delete the line but it would clear the placeholder from the final document.
Create an account or sign in to comment