Skip to main content
Participant
March 19, 2024
Question

this.importTextData(); not working, but manual import works fine

  • March 19, 2024
  • 2 replies
  • 1440 views

It has been three weeks and I have searched all over for an answer.

 

  1. I have a set of TXT files that are autogenerated every day from our electronic medical records sofware. 
  2. The filenames are dynamic (<formtype><office><date>.txt), soI'm requiring the end-user to manually select the files. 
  3. There are two rows:
  • The column headers  - matching all form field names (row 1 in Excel)
  • The field values - row "0" (row 2 in Excel)

 

When I import them through "Forms->Manage Data->Import Data", they work flawlessly and don't even require row selection.  I created a simple button with :

this.importTextData();

It allows me to select the file and then nothing happens.  In the debugger, I get a return value of "1".  To test, I edited to add the path and filename in a trusted folder-level script.  This imports fine, but there may be as many as 20 .of these TXT files and it would cause big mistakes if the wrong office or date was selected.

 

What am I doing wrong?

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
March 19, 2024

Worked fine for me... What version of Acrobat do you have?

Participant
March 19, 2024

@try67 , It's Acrobat X.  Old, I know.  But these files are used across a lot of users and we just don't have the capital at the moment to upgrade.

try67
Community Expert
Community Expert
March 19, 2024

And what's your OS?

Thom Parker
Community Expert
Community Expert
March 19, 2024

This function cannot open a txt file that is already open in another app. Close Excel before using this function.

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
March 19, 2024

@Thom Parker , thank you for your reply.  I really do wish it was that simple.  The file is not opened anywhere else, or by any other user.  In the past, I ran into that issue when I opened it in Notepad (to get rid of the "" around every value), and it wouldn't let me import it manually there, either.  

 

This is a file that works great when manually opening, but doesn't do a thing when assigned by script.