Skip to main content

Search

Search

Loading Files from Folder into DropDownList with VBScript

Comments

3 comments

  • Avatar
    Shotaro Ito

    Hello Brian,

    There's no other debug method than trial and error. I often do like

    msgbox("I'm here")

    From BarTender 2016 You have drop down item option to get source from files in a folder, so no need to use VB Script.

    About the script, At first, "Value" 's value wasn't defined so that's better be clear out. (don't try to keep "Value" from previous print etc)
    Try below..

    Value = "" 'Initialize Value

    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) = ".png") then
    fileNames = Left(fileNames,(Len(fileNames)-4))
    Value = Value & fileNames & vbCr 'Connect strings by &. add vbCr after filename to avoid 1st line to become empty
    End If
    Next
    0
  • Avatar
    Brian Jobmann

    Hello Shotaro,

     

    Thank you for your help. I actually had gotten this figured out, but I appreciate your effort. 

    The problem with using the built in dropdown list source from a folder, is two fold. One, the source seems to only be read when the filed is setup, not constantly (or at least at print time) as the artwork in that folder continues to change over time. So that was an issue. The second is that I could not hardwire the folder, as it needed to be based on the document folder. The document is a basis for the label setup. The user will copy and paste the document into new folders as government agencies require slight differences in the format of the date for instance. So I needed to be able to read the artwork files on demand so that the wrong artwork file could not be printed with the wrong format. Everything has to be separated. 

    Anyway, thanks for you attention I appreciate it. I have run into another problem though. I need to set the quantity at the time of print via the data form. No problem, I can do that no problem. But I need to write the number of copies to an audit log. The problem is that while I can link a data entry field to the print dialog copies, I can't get that back to the template VB to get that in the audit log. While it's a named source in the form, it's not a named source in the template. 

    I made a workaround, where I have a named datasource in the template - zCopies. I then linked the data entry for quantity on the form to zCopies. I then set the copies in the print dialog (the actual dialog) to "Set by Data Source" and set it to zCopies. This seems to work, but there is a very, very long delay (>120 seconds) between clicking print on the data form and BarTender actually processing the pages.

    Is there a better way? Can I access, via VB, the built in copies data source from the print dialog from a template like I can using the linked data source from the form? Or am I already doing it the best way?

    0
  • Avatar
    Shotaro Ito

    Hello Brian,
    Good to hear that you could overcome file listing part.
    Your procedure (name copy's data source) is right, and the setup itself should not slow down print job.

    I would try to identify what causes the slow down. such as

    • Number of records: Often bartender document opens slow when you have large database connected.
    • VB Script: What if you disable VB Scripts?
    0

Please sign in to leave a comment.