![]() |
|
#12
|
||||
|
||||
|
The following macro (Macro1) will help you tag content controls in selected text, but surely you would want to tag the controls before you send out the files, in order to be able to get a meaningful result?
The extraction add-in was suggested on the basis that you wanted to extract all the data from your form. It extracts to an Excel worksheet from which you can process the data. Alternatively you can use a macro to read ony the data required (see macro2) Code:
Sub Macro1()
TagControls "Q1Ans"
End Sub
Sub Macro2()
ReadControls "Q1Ans"
End Sub
Sub TagControls(strTag As String, Optional iStart As Integer = 0)
'Graham Mayor - http://www.gmayor.com - Last updated - 21 Jun 2018
Dim oCC As ContentControl
Dim i As Integer
For i = 1 To Selection.Range.ContentControls.Count
Set oCC = Selection.Range.ContentControls(i)
oCC.Tag = strTag & CStr(i + iStart)
oCC.Title = strTag & CStr(i + iStart)
DoEvents
Next i
lbl_Exit:
Set oCC = Nothing
Exit Sub
End Sub
Sub ReadControls(strTag As String)
Dim oCC As ContentControl
Dim oSource As Document
Dim oDoc As Document
Set oSource = ActiveDocument
Set oDoc = Documents.Add
For Each oCC In oSource.ContentControls
If oCC.Tag Like strTag & "*" Then
If oCC.ShowingPlaceholderText = False Then
oDoc.Range.InsertAfter oCC.Range.Text & vbCr
End If
End If
DoEvents
Next oCC
lbl_Exit:
Set oCC = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
| Tags |
| delete text |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple versions of document in one (i.e. hide section) | MatKus | Word | 4 | 03-20-2018 05:53 AM |
| Is there a way to modify multiple versions of a document simultaneously? | junkman | Word | 6 | 09-08-2017 07:37 AM |
Saving multiple versions of a file automatically
|
NickPetrofski | Word | 7 | 07-31-2017 04:14 PM |
| Batch processing:How to format multiple images (art effects & color) and then save them,all at once? | spbone | Word VBA | 2 | 01-12-2016 04:46 AM |
| Multiple versions of Office on the same network. | whatrudoingdave | Office | 1 | 04-30-2012 03:36 PM |