Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2013, 04:59 AM
jeffaus jeffaus is offline How to retrieve text from a word content control in VBA Windows Vista How to retrieve text from a word content control in VBA Office 2007
Novice
How to retrieve text from a word content control in VBA
 
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
  #2  
Old 03-14-2013, 11:42 PM
macropod's Avatar
macropod macropod is offline How to retrieve text from a word content control in VBA Windows 7 64bit How to retrieve text from a word content control in VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi jeffaus,

There is no such thing in Word as a 'ContentControlsbyTag' method. What Word has is a SelectContentControlsByTag method.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve text from a word content control in VBA Creating a plain text content control for every instance of a word or phrase RobsterCraw Word VBA 16 11-20-2012 03:25 PM
How to retrieve text from a word content control in VBA How do you set rich text in a content control Testor Word VBA 4 07-08-2012 07:55 AM
How to retrieve text from a word content control in VBA Rich Text Content Control - Allow User Formatting keithacochrane Word 1 05-28-2012 05:06 PM
How to retrieve text from a word content control in VBA content control Word 2007 TessaLee Word 1 03-11-2011 12:51 AM
Templates: automatic text generation from Rich Text content control Chickenmunga Word 0 10-01-2008 11:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:34 AM.


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