Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-17-2017, 03:40 AM
gmayor's Avatar
gmayor gmayor is offline Combining dropdown list VBA and data repeat VBA Windows 10 Combining dropdown list VBA and data repeat VBA Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The line in question writes the text from the content control to a customdocument property called "Sbjct". If that document property doesn't exist you will get an error (hence the comment two lines before this one).

Alternatively you could change the document property references to document variables (and use docvariable fields to display the variable content) e.g.
Code:
Case "Sbjct": ActiveDocument.Variables("Sbjct").Value = ContentControl.Range.Text
This doesn't require the variable to pre-exist but it will crash if the content control is empty so you need to trap that (and the default text) e.g.
Code:
Case "Sbjct"
                If Not ContentControl.Range.Text = "" _
                   And Not ContentControl.Range.Text = ContentControl.PlaceholderText Then
                    ActiveDocument.Variables("Sbjct").Value = ContentControl.Range.Text
                End If
You will of course have to treat all those documentproperty entries similarly
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining dropdown list VBA and data repeat VBA How do I make a checkbox or dropdown item reference data in that specific section of the data array? dhare Excel Programming 2 02-24-2016 12:36 PM
Help!! Dropdown List christo16 Word 1 06-29-2015 05:18 AM
combining 2 or more columns of numerical data or text data heartdoc Excel 0 12-03-2014 10:57 PM
Populate dropdown list with data from Access table spw4000 Office 0 02-24-2012 05:22 AM
Using fields to repeat data throughout a document Brasada Word 0 07-20-2010 02:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:06 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