0

Is there any way to create (and display) multi-lined DOCVARIABLE without VBA? I.e. "One\r\nTwo\r\nThree" renders into One Two Three

Belegnar
  • 721
  • 10
  • 24

1 Answers1

0

Please try the following:

{ DOCVARIABLE  TestVar  \* MERGEFORMAT }


Sub DocVars()
    Dim arr As Variant, joinSting As String
    arr = Array("One", "Two", "Three", "Four", "Five")
    joinSting = Join(arr, vbNewLine)
    ActiveDocument.Variables("TestVar").Value = joinSting
End Sub

Output:

  • thx! it works, but creates new paragraphs, not new lines inside paragraph anyway, i didn't going to use VBA - have corrected original post – Belegnar Dec 04 '17 at 09:44
  • AFAIK, you can't use `DOCVARIABLE` without `VBA`. Please refer this [link](https://support.office.com/en-us/article/Field-codes-DocVariable-field-32a81e22-c5c1-4b16-8097-f0de851db67c?ui=en-US&rs=en-US&ad=US). –  Dec 04 '17 at 10:19
  • DOCPROPERTY is ok for me. Thank you – Belegnar Dec 05 '17 at 17:22