![]() |
|
#1
|
|||
|
|||
|
I'm looking for a way to spell out numbers (not currency) typed into a content control without protecting the document. I.e., if someone enters 31,000, "thirty-one thousand" would appear in front of it. I know how to do this with legacy forms but that requires me to protect the document. I'm already using a bunch of content controls and those who will be editing this template will be editing more areas than just those with content controls. Is there a way I can do this using content controls but without protecting the document?
I've played around with VBAs a few times so I understand the basics but the simpler, the better. If that's not possible, I will most likely need some explaining. Also, if it makes a difference, this would be utilized in more than one location in the document. Thank you! |
|
#2
|
||||
|
||||
|
If you title the content control into which you input the number 'NumVal' and a Rich Text content control titled 'NumText' for the words, you could use a content control on exit macro like:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Dim StrNum As String
With CCtrl
StrNum = Trim(.Range.Text)
If IsNumeric(StrNum) Then
If .Title = "NumVal" Then
With ActiveDocument
.Fields.Add Range:=.SelectContentControlsByTitle("NumText")(1).Range, _
Type:=wdFieldEmpty, Text:="=" & StrNum & " \* CardText", PreserveFormatting:=False
.SelectContentControlsByTitle("NumText")(1).Range.Fields.Unlink
End With
End If
End If
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
This worked perfectly. Thank you!
|
|
| Tags |
| content control, vba, word 2010 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Protecting document | brucemc777 | Word | 2 | 01-23-2016 02:38 PM |
Protecting a document; allow sections to be edited - spacing in table cells when protected
|
dwciardi | Word | 3 | 09-30-2015 01:03 PM |
Cant type into content controls in a form after protecting document using macro
|
rgburridge | Word VBA | 4 | 01-27-2015 02:37 PM |
| Disabling content controls and protecting document sections. | Catty | Word VBA | 2 | 11-29-2013 05:10 AM |
| Protecting Word Document by restricting access permissions! | user | Word | 0 | 11-20-2008 01:21 PM |