Skip to main content
vanessal94397107
Known Participant
August 6, 2017
Question

How do I open file to import data into a form from .txt file on mouse click?

  • August 6, 2017
  • 5 replies
  • 4139 views

I would like to be able to click on textbox "patient name" and have this open my .txt file created from excel spreadsheet to choose patient data to import.  I know how to go through the menu items to select this, but I am trying to make it a bit more automated.  I tried using the "action" tab in the text box to "execute Menu Item" but the menu option to import data was not available.

Thanks for the help.

This topic has been closed for replies.

5 replies

vanessal94397107
Known Participant
August 6, 2017

yeah its the creating part I dont know how to do.  The articles are very useful in understanding why something is done a certain way, but if you don't know where to start the code...you only get so far.   I have found a lot of information on what a trusted function is and how to create the .js file and where to put it.  Just don't have the slightest idea on how to actually created a trusted function from scratch and cant find an example for what I am trying to do. 

vanessal94397107
Known Participant
August 6, 2017

So I read the link you sent.  Very informative and I thought I understood several of the options.  I added the files and path folder of my desktop to the trusted locations under the security preferences.  that didn't work.  then I attempted to access the javascripts folder in programs to try another options, but this is a work computer and I do not have permissions to make changes to that folder.  Any more help would be appreciated for this novice.

Inspiring
August 6, 2017

You should have access the user application folder. The location of this folder will be dependent upon the type of computer, and version of Acrobat.

vanessal94397107
Known Participant
August 6, 2017

Ok making baby steps of progress.  Found the correct javascripts folder that I can save to.  There is a js file in there called glob that appears to be empty.  So I just copy "this.importTextData();"  with the correct file path?  Im not sure what to do next. 

vanessal94397107
Known Participant
August 6, 2017

The file would be pulled from a shared network drive that all users have access to.

try67
Community Expert
Community Expert
August 6, 2017

That's not the issue. The issue is that the script to access that file needs to be installed on the computer of each user.

vanessal94397107
Known Participant
August 6, 2017

that's not a big problem to solve in my situation.  I downloaded the file to my local desktop and still got a security settings error though.  

NotAllowedError: Security settings prevent access to this property or method.

Doc.importTextData:1:Field Click:Mouse Up

vanessal94397107
Known Participant
August 6, 2017

Ok that worked.  Is it possible to enter a default file path to the file I need?

try67
Community Expert
Community Expert
August 6, 2017

You can specify the file path but it would require running the script from a privileged context (ie, a script installed on the user's local machine).

try67
Community Expert
Community Expert
August 6, 2017

Use this JavaScript code:

this.importTextData();

However, I don't recommend using the text field's MouseUp event for this. Use a separate button field, instead.