Loading Files from Folder into DropDownList with VBScript Follow
Hello. Having trouble loading a DropDownList into a form in BarTender. I have a Document (there will be many) located in a folder. The label requires artwork (many different options) and they will be located in the same folder as the document file. I have set up Named Data Sources to get the path of the folder (as that will vary from Document to Document depending on the folder it is located in). These are working perfectly.
I set up the VB Script to populate the DropDownList, and in the VB Script Editor, it appears to be working. The output is correct. When I go to print preview, all but one time, I get a "<Script Error>". I don't know how to debug this when its working in the script editor, and when it worked once in the in the print preview. I have added the path to the form to make sure its value is correct and it is.
So two questions:
1. Obvious, what am I doing wrong?
2. Is there more debugging that can be recommended at the runtime so I can figure out what's going on?
I downloaded the latest release today, and still am having the issue. I am running the 32-Bit version on Windows 7.
Here is the my VB Script:
Dim dir, foundFile
dir = Format.NamedSubStrings("Path").Value
Dim fileNames, fso, folder
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(dir)
For Each foundFile In folder.Files
fileNames = foundFile.name
If(Right(fileNames,4) = ".pdf") then
fileNames = Left(fileNames,(Len(fileNames)-4))
Value = Value + vbCR + fileNames
The output seems correct, although there is a blank line above the file names. This is consistent when I close the script editor, and look at the DropDown List Properties --> List Items. There is a blank row there as well.
It almost seems that I need to reset the list to empty before running the script. Which, would actually be good, because artwork could be added to the folder between print jobs, and the dialog will stay open after each print job ready for the next job.
Any help would be GREATLY appreciated. And if you need screen shots, let me know and I will get them to you. Thanks for your help in advance!
Please sign in to leave a comment.