![]() |
#1
|
|||
|
|||
![]()
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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
MMT | Excel | 9 | 02-12-2015 09:18 PM |
![]() |
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 |