Jump to content
Server Maintenance This Week. ×

360 Scribe - Replacing multiple fields for Word Doc


This topic is 2240 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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 by kims
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 2240 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.