View Single Post
 
Old 03-13-2013, 04:59 AM
jeffaus jeffaus is offline Windows Vista Office 2007
Novice
 
Join Date: Mar 2013
Posts: 1
jeffaus is on a distinguished road
Default How to retrieve text from a word content control in VBA

Hi All

I am new to VB and I'm having difficulty retrieving text from a content control

Below is the code that i have come up with but it doesn't seem to work.
When I use the {valuecc = "test"} line it works but when i try the line below it doesn't.
Can anyone tell me where i'm going wrong?

Thanks
Jeffaus

Code:
Private Sub Swapcc(doc As Document, tagcc As String)
Dim cc As ContentControl
Dim valuecc As String
'valuecc = "test"
valuecc = ActiveDocument.ContentControlsbyTag(tagcc).Range.Text
 
For Each cc In Documents(doc).ContentControls
  If cc.tag = tagcc Then
    cc.Range = valuecc
  End If
Next
End Sub

Last edited by macropod; 03-14-2013 at 11:38 PM. Reason: Added code tags & formatting
Reply With Quote