Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-13-2018, 04:16 AM
SuziBaz SuziBaz is offline VBA for ContentControl returning multiple lines of text Windows 10 VBA for ContentControl returning multiple lines of text Office 2016
Novice
VBA for ContentControl returning multiple lines of text
 
Join Date: Apr 2018
Posts: 3
SuziBaz is on a distinguished road
Default 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
Can anyone please advise?

Last edited by SuziBaz; 04-13-2018 at 06:18 AM. Reason: Added code tags
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA for ContentControl returning multiple lines of text 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
VBA for ContentControl returning multiple lines of text Extracting data from a cell with multiple lines of text MMT Excel 9 02-12-2015 09:18 PM
VBA for ContentControl returning multiple lines of text 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft