text file printing problem S’abonner

0
Avatar
Nipe kangas

Hello


So I have text file that has 20 lines for example. In each line there is 2 "," (Comma) that separate 3 different values. my intentions is that for each line in this text file there would be 1 label per line with the label having these 3 values from that one line in that one label. Resulting in 20 labels with each having different values, but the code that would execute this only shows the last line on every label that is supposed to be printed. These files are chosen through a form that has text input box. 

The reason for this code is that within text file the lines change so much that from each other that bartender itself cannot keep up with the random increments that the text file has.

So my first question would be that is this even possible to do with bartender and if it is how can i accomplish this.


Here's a snipped from the code


Sub Fileprint
Const ForReading = 1
Dim A, B, C
Dim BarFile
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
on error resume next
Set BarFile = ObjFSO.OpenTextFile("C:\Users\test.txt",ForReading)
if err.number <> 0 Then
on error goto 0
msgBox "Can’t find text file ."
Format.CancelPrinting(Message)
end if
strText = BarFile.ReadAll
msgbox "." & strText & "."
BarFile.Close
File = Split(strText, vbCrLf)
For Each strText in File
if StrText <> "" then
LBL = Split(strText, ",")
Format.NamedSubStrings("A ").Value = LBL(0)
msgbox "." & Format.NamedSubStrings("A ").Value & "."
Format.NamedSubStrings("B").Value = LBL(1)
msgbox "." & Format.NamedSubStrings("B").Value & "."
Format.NamedSubStrings("C").Value = LBL(2)
msgbox "." & Format.NamedSubStrings("C").Value & "."
end if
next
End Sub

 

Thank you

2 commentaires

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Why cant you just link to the file as a text database, linking the appropriate fields on the label to the three data fields in the file? 

If the data is variable length in each field from record to record, you can just set the fields as multi-line fields or with auto-sizing of the text etc.. 

0
Avatar
Nipe kangas
Actions pour les commentaires Permalien

oh sorry i forgot to mention that there is an entire folder of these files and text database works with just one text file. I haven't gotten text database to work with entire folder.

So first i would need to select from that folder that one file that needs to be printed then distribute whats inside of that text file to the label and print the label.

Vous devez vous connecter pour laisser un commentaire.