Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2015, 03:01 AM
dsimon14 dsimon14 is offline How to set the Content Control placeholder default text Windows 7 64bit How to set the Content Control placeholder default text Office 2003
Novice
How to set the Content Control placeholder default text
 
Join Date: Mar 2015
Posts: 2
dsimon14 is on a distinguished road
Default How to set the Content Control placeholder default text

Hi,

I'm designing word documents as templates for my web application. I'm using content controls to be able to get the content of the document in Java. I'm using Word 2010.

When you create a content control, it sets a default placeholder text where it's written "Click here to enter text" (for input fields for example). I like this feature because my users can just click anywhere and it's automaticaly replaced by the text typed.

What I'd like to do is to set The default message in French and German for my others documents.

I've tried some tricks but nothing works. Something like that :

Code:
 
Sub temp1()
  Dim aCC As ContentControl
  For Each aCC In ActiveDocument.ContentControls
       aCC.SetPlaceholderText , , "Now I can see the placeholder text"
  Next aCC
End Sub
I've read somewhere that I needed to turn on the formDesign mode, Toggling to design mode is working but it still doesn't work and I can't toggle it back :



Code:
Dim toggleDesignMode As Boolean
toggleDesignMode = ThisDocument.FormsDesign
 If (toggleDesignMode) Then
    ThisDocument.ToggleFormsDesign
 End If
 
Dim aCC As ContentControl
  For Each aCC In ActiveDocument.ContentControls
    If aCC.Tag = "SecteurActivite" Or aCC.Tag = "Pays" Then
        aCC.SetPlaceholderText , , "Choose an item."
    ElseIf aCC.Tag = "NomClient" Or aCC.Tag = "Site" Or aCC.Tag = "DureeProjet" Or aCC.Tag = "AnneeRealisation" Or aCC.Tag = "Description" Or aCC.Tag = "LibelleProjet" Or aCC.Tag = "SousTitre" Or aCC.Tag = "Benefices" Then
         aCC.SetPlaceholderText , , "Click here to input text"
    Else
        aCC.SetPlaceholderText , , "no reason to display this one"
    End If
 
  Next aCC
'This is not working !
ThisDocument.ToggleFormsDesign
I would be really thankful for any help !
Reply With Quote
  #2  
Old 03-27-2015, 04:53 AM
gmayor's Avatar
gmayor gmayor is offline How to set the Content Control placeholder default text Windows 7 64bit How to set the Content Control placeholder default text Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
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 of
Default

You don't need to toggle the design mode

Code:
Dim aCC As ContentControl
    For Each aCC In ActiveDocument.ContentControls
        Select Case aCC.Tag
            Case "SecteurActivite", "Pays"
                aCC.SetPlaceholderText , , "Choose an item."
            Case "NomClient", "Site", "DureeProjet", _
                 "AnneeRealisation", "Description", "LibelleProjet", _
                 "SousTitre", "Benefices"
                aCC.SetPlaceholderText , , "Click here to input text"
            Case Else
                aCC.SetPlaceholderText , , "no reason to display this one"
        End Select
    Next aCC
will do the job.
__________________
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
  #3  
Old 03-27-2015, 05:03 AM
gmaxey gmaxey is offline How to set the Content Control placeholder default text Windows 7 32bit How to set the Content Control placeholder default text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Your first snippet of code works here just fine. What happens when you run that code on your active document containing CCs?
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 03-27-2015, 07:15 AM
dsimon14 dsimon14 is offline How to set the Content Control placeholder default text Windows 7 64bit How to set the Content Control placeholder default text Office 2003
Novice
How to set the Content Control placeholder default text
 
Join Date: Mar 2015
Posts: 2
dsimon14 is on a distinguished road
Default

I just discovered that I could execute directly the macro ^^ (yeah I'm pretty new to vba/macros).
I was using the document_open event.

I tried executing the macro, it doesn't do anything. In the step by step it seems that ActiveDocument.ContentControls is empty (ActiveDocument shows my file and seems to be ok).
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there VBA to paste text into content control? kintap Word VBA 2 07-02-2014 07:42 AM
Limit text length Content Control NobodysPerfect Word 10 02-28-2014 02:40 PM
How to set the Content Control placeholder default text Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM
How to set the Content Control placeholder default text How do you set rich text in a content control Testor Word VBA 4 07-08-2012 07:55 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 05:36 PM.


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