Form field data to word file template using java script?

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Using Tap Forms Form field data to word file template using java script?

Tagged: 

Viewing 6 reply threads
  • Author
    Posts
  • October 16, 2020 at 7:34 AM #42289

    Chris Ju
    Participant

    Hello,

    has anyone tried to fill a fields in a Word file (template in Finder) with data from form fields using java script and adding this Word file to a record as file attachment?

    Is that even possible?

    Thanks.

    Chris

    October 17, 2020 at 11:47 PM #42295

    Sam Moffatt
    Participant

    I thought I’d replied to this but I guess I didn’t hit submit or something.

    My immediate thought would be to use the clipboard to shuttle data around, encode it in Tap Forms and then use VBA to grab the clipboard and splice it into the template, if you put the file in the script directory for Tap Forms then you might be able to attach it via a script as well though it’s a little janky all told.

    Some other folk have had success with AppleScript and also Keyboard Maestro that might be able to automate things.

    I’m not sure any of it is a good solution for automating Word but that might help you along.

    October 18, 2020 at 11:48 PM #42296

    Chris Ju
    Participant

    My idea was to replace text/field (e.g. “nName”, “aAddress”, …) in the docx (=xml) file with the content from Tap Forms fields (name, address, …) using javascript. I know, that it is possible with apple script in other apps…

    October 19, 2020 at 12:28 AM #42297

    Brendan
    Keymaster

    I don’t know how you would open a docx XML file within JavaScript, then update it and save it back. I don’t think the JavaScriptCore framework I use in Tap Forms would allow that. So Sam’s solution of copy and paste might work. Tap Forms can set values on the clipboard from a Script.

    But if you don’t need a Word file for this task, you could use Tap Forms with a custom layout and a static Text object on the layout. Within the text object, insert the field names with square brackets around the names and when you print, Tap Forms will substitute the values.

    For example:

    Dear [First Name] [Last Name],
    
       We have come to the realization that you need to pay $[Amount Due] by [Due Date] or you will be charged an additional [Penalty Percent]% interest on your loan.
    
    Sincerely,
    
    The Lending Company

    You can even stylize the text within the Text object.

    To add a Text object, click the Layout button, then click the A button above the layout inspector panel. Then click on your layout and type in your form. You can even paste from Word into there. But I would probably paste as plain text to remove any formatting and then use Tap Forms to format. Word might add all kinds of crap into the formatting that you don’t want.

    If you need more than one page though, you can add another layout and then chain the layouts together.

    Thanks!

    Brendan

    October 19, 2020 at 12:45 AM #42300

    Chris Ju
    Participant

    Thanks for the hint.

    I’m already using layouts as you described. But the main problem is, using layouts with long texts (so one have to use many layouts)… That is the reason i want to transfer field data from Tap Forms to the docx file …

    Thanks!
    Chris

    October 20, 2020 at 1:26 AM #42318

    Brendan
    Keymaster

    Ah ok. I understand. I would like to enhance the layout engine to allow multiple pages per layout and have a text block span multiple pages automatically. On my wish list.

    October 20, 2020 at 1:32 AM #42320

    Chris Ju
    Participant

    That is on my wish list, too!

    Do you know someone who can grant wishes? ;-)

    Thanks!
    Chris

Viewing 6 reply threads

You must be logged in to reply to this topic.