Zum Hauptinhalt gehen

Suche

Suche

Drop Down List With .txt File Instead Of .xlsx

Kommentare

3 Kommentare

  • Avatar
    Shotaro Ito

    Hi,

    I thought there was - though I couldn't find that in the forum. try below:

     

    Function and Subs:
    
    Function GetNamesFromText(textPath)
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set txtFile = fso.OpenTextFile(textPath, ForReading, TristateFalse)
      options = ""
      Do Until txtFile.AtEndOfStream = true
          options = options & txtFile.ReadLine & vbCr
      Loop
      txtFile.Close
      set txtFile = Nothing
      set fso = nothing
      GetNamesFromText = options
    End Function
     
    OnFillList:
    Value = GetNamesFromText("c:\listitems.txt")
    

    example of list items - plain text file with a entry per line.

    John Smith
    Taro Yamada
    Mario Rossi
    

    If you specify ".\filename.txt", it picks from the same folder as btw document.

     

    In case someone need OLEDB connection string for CSV text with column header, it goes like this.

     

    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""c:\tmp\"";Extended Properties=""Text;HDR=YES;FMT=Delimited"""
    ...
    Set rs = objConn.Execute("SELECT * FROM listitem.csv")
    0
  • Avatar
    Legacy Poster

    Hello,

    I am currently trying to set up some templates for a client and wanted to incorporate some dropdown lists that link to a database.

     

    This VB script in this post was helpful but the VB script in the post applies the one field to both the 'Display Text' and the 'Data Source Value'. I would like to modify it so that the dropdown list "Display Text' reads from one field and the 'Data Source Value' reads from another field from the same excel spreadsheet. 

     

    Any help would be appreciated.

     

    We are resellers of Bartender software and TSC printers.

    0
  • Avatar
    Shotaro Ito

    answered in this topic.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.