Copy link to clipboard
Copied
i have excel file has just 2 colomns but contains 3000 names and thier ID, it will be difficult to put all this data mnually in my script:
function PopulateFlightCrewCode() { for (var i=1; i<9; i++) { this.getField("code." + i).setItems([
["", ""],
["75428", "ABDALLAH BAHEY"],
]); } }
can i find way to extract automatically the data from the excel sheet as the underlined script ?
thanks in advance
Copy link to clipboard
Copied
Copy the contents of the Excel spreadsheet to a plain-text file. I recommend using something like Notepad++. Then use the Search and Replace command (with Reg Exp option enabled) and replace all instances of [\t] with [", "], and [\r\n] with ["],\r\n["] (search terms are in red square brackets).
Then fix the first and last lines, and your code is ready!
Another option is to use a script to do it directly. For example, this (paid-for) tool I've created will allow you to import the contents of a spreadsheet (after you saved it as a plain-text file) to the drop-down, including export values, if you wish to do so: https://www.try67.com/tool/acrobat-import-items-from-a-text-file-to-a-combo-box-or-list-field
Copy link to clipboard
Copied
Copy the contents of the Excel spreadsheet to a plain-text file. I recommend using something like Notepad++. Then use the Search and Replace command (with Reg Exp option enabled) and replace all instances of [\t] with [", "], and [\r\n] with ["],\r\n["] (search terms are in red square brackets).
Then fix the first and last lines, and your code is ready!
Another option is to use a script to do it directly. For example, this (paid-for) tool I've created will allow you to import the contents of a spreadsheet (after you saved it as a plain-text file) to the drop-down, including export values, if you wish to do so: https://www.try67.com/tool/acrobat-import-items-from-a-text-file-to-a-combo-box-or-list-field
Copy link to clipboard
Copied
where i can find [\t] in the notepad++ ?
Copy link to clipboard
Copied
\t just means tabs. Remove the tabs using the find and replace tool.
There is also a free PDF file here that contains code for loading copied and pasted text into a list/dropdown field. Which is a good place to keep this kind of data.
https://www.pdfscripting.com/public/Free-Sample-PDF-Files-with-scripts.cfm
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
thank you mr thom, but i want to put this in one loop script not in the dropdown list, because i want to populate this data for 20 dropdown list.
if i used your file, i have to insert the value manually for each item, which will be more time
i am trying to use this sccript to get the item and the value at the same time
but i can not enter the 3000 name with ID from the excel sheet automatically in the brackets
function PopulateFlightCrewCode() { for (var i=1; i<9; i++) { this.getField("code." + i).setItems([
["", ""],
["75428", "ABDALLAH BAHEY"],
]); } }
Copy link to clipboard
Copied
Well actually, the idea is just to get the data in a form that can be used by Acrobt JavaScript. Whether it's hard coded in a script, or in a form field. Either way you can then use a script to copy the data somewhere else. That's the beauty of code. You can make it do almost anything you want automatically, so you don't have to do things manaually.
So the free PDF file contains code for copying the data out of a text field and into a dropdown. It's pretty close to exactly the code you need. You would benefit greatly from downloading the file and examining the script.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
You don't find it, you enter it, like this:
Copy link to clipboard
Copied
thank you so much but i am really can not do this, if you please give me another help
Copy link to clipboard
Copied
This is not Notepad++, which isn't available for Macs. I can't help you further, since I'm not a Mac guy and don't know what the equivalent there would be.
If you want I can do it for you, for a small fee. You can contact me privately via [try6767 at gmail.com] to discuss it further, if you wish.
Copy link to clipboard
Copied
Probably the closest you will get to Notepad++ is BBEdit.
https://www.barebones.com/products/bbedit/
After the trial runs out, you can still run it with limited functions (but still powerful).
Copy link to clipboard
Copied
it works, it did it by windows
thank you so much
Copy link to clipboard
Copied
i have excel file has just 2 colomns but contains 3000 names and thier ID, it will be difficult to put all this data mnually in my script:
function PopulateFlightCrewCode() { for (var i=1; i<9; i++) { this.getField("code." + i).setItems([
["", ""],
["75428", "ABDALLAH BAHEY"],
]); } }
can i find way to extract automatically the data from the excel sheet as the underlined script ?
thanks in advance
By abdallam73011229
Copy link to clipboard
Copied
>>it will be difficult to put all this data mnually...
I don't know what you want these to look like in InDesign, but you could just move the columns together, create a named region in Excel, and place the named region.

