#1
|
|||
|
|||
VBA for ContentControl returning multiple lines of text
I'm new to VBA and am trying to create VBA for a form in which a user will choose an option (Grade 1, 2 or3) from a Content Control Dropdown list and then the text will return as variable text.
The issue I am having is that the returned text has multiple lines (about 12) which need to be on individual lines and the VBA I am using is not returning this on individual lines. I am using & Chr(10) & and also I have tried & vbLf & and also & vbNewLine & The VBA sample is below: Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim i As Long, StrDetails As String, StrDesc As String With ContentControl If .Title = "Grade" Then For i = 1 To .DropdownListEntries.Count If .DropdownListEntries(i).Text = .Range.Text Then StrDetails = .DropdownListEntries(i).Value If StrDetails = "Grade 1" Then StrDesc = "All new employees with less than two years employment will be entitled to Statutory Sick Pay." & vbLf & "After two years employment the Company will supplement the statutory sick pay of qualifying employees to an amount equivalent to the full basic wage level to the periods indicated below." ElseIf StrDetails = "Grade 2" Then StrDesc = "Text to be added here" ElseIf StrDetails = "Grade 3" Then StrDesc = "Text to be added here" End If Exit For End If Next With ActiveDocument With .SelectContentControlsByTitle("txtGrade")(1).Range If StrDesc <> "" Then .Text = StrDesc End If End With End With End If End With End Sub Last edited by SuziBaz; 04-13-2018 at 06:18 AM. Reason: Added code tags |
#2
|
|||
|
|||
Try chr(13)? Multiline content control is a bit tricky, hope someone else can help.
|
#3
|
|||
|
|||
Unfortunately this doesn't work either
Let's hope there's someone out there that is a Whizz on multiline content control |
#4
|
||||
|
||||
@Suzi
Hello and welcome in the future could you please wrap your code with code tags ? ( click Go advanced - select code and click the #button) Thank you
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#5
|
|||
|
|||
Thank you Pecoflyer...Duly Noted
|
#6
|
||||
|
||||
Cross-posted (and answered) at: https://www.mrexcel.com/forum/genera...ines-text.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to insert bookmarks for content or Text of ContentControl | lvganesh | Word VBA | 5 | 12-12-2017 11:27 PM |
Returning value based on multiple crtiteria | stockers | Excel | 3 | 03-06-2017 05:05 PM |
Extracting data from a cell with multiple lines of text | MMT | Excel | 9 | 02-12-2015 09:18 PM |
Multiple lines of placeholder text | hanilucida | PowerPoint | 1 | 06-21-2014 05:40 AM |
Macro to Insert Text Into Cells Having Multiple Lines | revans611 | Excel Programming | 4 | 10-24-2011 10:15 AM |