Saltar al contenido principal

Búsqueda

Búsqueda

Insert line breaks within a word from a data source

Comentarios

9 comentarios

  • Avatar
    Peter Thane

    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
  • Avatar
    Carmen Amerhauser

    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
  • Avatar
    Peter Thane

    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
  • Avatar
    Carmen Amerhauser

    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
  • Avatar
    Peter Thane

    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
  • Avatar
    Carmen Amerhauser

    Yes, I´ve done it. But in my case if I select the data source I get this:

    value = Format.NamedSubStrings("printName").Value

    0
  • Avatar
    Peter Thane

    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
  • Avatar
    Carmen Amerhauser

    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
  • Avatar
    Peter Thane

    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.