Insert line breaks within a word from a data source
I want to print a label from a database that contains names longer than 20 characters. Every time I try to print, the print name is adjusted to fit the width of my field, which makes the print name smaller. My settings should actually cause the word to wrap, but unfortunately that doesn't happen. Only with embedded data does it work. How do I manage to induce a word wrap from my external data? The technical support suggested I use a VB-Script. Could anyone help with that?
Thank you in advance
Carmen
-
Peter Thane
★ BarTender Hero ★
There maybe a simpler way but this works
If you source data is coming from a database then your first line should be Value = and then double click on the database field name that will appear in the column on the right. If from a different field then I would suggest making that a Named Data Source and then, similar to the above, pick the name from the Name Data Sources section that will be displayed on the right.
0 -
Carmen Amerhauser
★ BarTender Hero ★
Thank your very much for your help!
I tried it but unfortunately it does not work with my external data source. Additionally, if the source is smaller than 20 characters I get an error.
Do you by chance know why I does not work with my external data source?
Thanks again!
0 -
Peter Thane
★ BarTender Hero ★
Make the field an Event Controlled Script and run the VB on the OnNewRecord option.
Add another If...then...else command so that If the length in Value1 is less than 20 Then Value = Value and then make the rest of the code the Else part of this
0 -
Carmen Amerhauser
★ BarTender Hero ★
Thank you so much. The script works for embedded data but unfortunately the link to my external data source is gone (data source: <empty>; emtpy space is printed). It seems like my data source was exchanged by the VB script rather than connected to it.
Would be so nice of you if you have a solution for that as well. Thanks in advance
0 -
Peter Thane
★ BarTender Hero ★
Have you made the VB and Event Controlled Script > OnNewRecord and have you amended the first line (Value = ) to link to your database field by selecting it from the Script Assistant column on the right?
0 -
Carmen Amerhauser
★ BarTender Hero ★
Yes, I´ve done it. But in my case if I select the data source I get this:
value = Format.NamedSubStrings("printName").Value
0 -
Peter Thane
★ BarTender Hero ★
Not sure, the code works for me
This was the VB I used
Value = Format.NamedSubStrings("longdata").Value
Value1 = Len(Value)
If Value1 > 20 then
Value2 = Left(Value,20)
Value3 = Value1 - 20
Value3 = Right(Value,Value3)
Value = Value2 & vbCR & Value3
else Value = Value
end if
0 -
Carmen Amerhauser
★ BarTender Hero ★
In theory, so when I test the script, this works also for me. But not if I print the actual label. Even with embedded data: there is no line break induced.
0 -
Peter Thane
★ BarTender Hero ★
Sorry not sure what to suggest then. The only thing you could check is that the field is set to Wrap but the Autosize option is turned off in the field setup on the Text Format and Auto Fit tabs
0
Iniciar sesión para dejar un comentario.
Comentarios
9 comentarios