Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-30-2017, 05:43 AM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default Insert Rich Text Content Control in specific position, Word 2013 VBA


Is it possible to insert a rich text control control into a particular position in a Word doc template.

I have the following which works fine for a shape, but not the rich text control.

Set shp = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=5, Width:=500, Height:=41)
shp.TextFrame.TextRange.Text = "Please add company name"
shp.TextFrame.TextRange.Style = oStyle
shp.Line.Visible = msoFalse
shp.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shp.Top = InchesToPoints(1.1)
shp.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
shp.Left = InchesToPoints(0.27)

Thanks in advance.
Reply With Quote
  #2  
Old 11-30-2017, 06:17 AM
gmayor's Avatar
gmayor gmayor is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows 10 Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2016
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

A content control is not a shape, which can be independent of the text and thus placed anywhere, but is essentially a text item. it has the same characteristics with regard to placement as text typed from the keyboard.
__________________
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 11-30-2017, 06:22 AM
macropod's Avatar
macropod macropod is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows 7 64bit Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Quote:
Originally Posted by gmayor View Post
A content control ... has the same characteristics with regard to placement as text typed from the keyboard.
And, as such, you could insert it into a textbox or floating table and position it that way.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 11-30-2017, 06:24 AM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

Ok, understood. That's clear. What would you recommend I insert that can be used as a text placeholder into which the user will type "Insert Company Name" but will sit in the header position, not shift onto the next page, but can be picked up as a Style for the table of contents. My shape (as per the code provided) moves onto the next page despite "move with text" not being checked, and "lock anchor being checked". With thanks
Reply With Quote
  #5  
Old 11-30-2017, 06:25 AM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

Hi I tried that, but it still jumped onto the same page, even with the layout settings as described.
Reply With Quote
  #6  
Old 11-30-2017, 09:37 AM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

I found that if I group the two textboxes, they stay put. I need to do this via VBA, however. What is wrong with this code

Set shp = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=5, Width:=500, Height:=41)
shp.TextFrame.TextRange.Text = "Please add company name"
shp.TextFrame.TextRange.Style = oStyle
shp.Line.Visible = msoFalse
shp.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shp.Top = InchesToPoints(1.1)
shp.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
shp.Left = InchesToPoints(0.27)
shp.Name = Shape1

Selection.GoTo What:=wdGoToPage, Which:=wdseekcurrent
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPage
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Set shp2 = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=5, Width:=500, Height:=41)
shp2.TextFrame.TextRange.Text = "Please add title"
shp2.TextFrame.TextRange.Style = bStyle
shp2.Line.Visible = msoFalse
shp2.RelativeVerticalPosition = wdRelativeVerticalPositionPage
shp2.Top = InchesToPoints(1.5)
shp2.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
shp2.Left = InchesToPoints(0.27)
shp2.Name = Shape2
With Selection.ShapeRange
.LockAnchor = True
End With

ActiveDocument.Shapes.Range(Array("Shape1", "Shape2")).Select
Selection.ShapeRange.Group

It doesn't group the two. Can anyone assist
Reply With Quote
  #7  
Old 11-30-2017, 01:46 PM
macropod's Avatar
macropod macropod is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows 7 64bit Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Perhaps you could explain why the particular content needs to be 'in the header position' instead of in the body of the page concerned? From what you've described, it would appear you can achieved the same visual outcome with a small top margin and a 'different first page' layout, with some additional padding content to increase the effective header size on the 2nd & subsequent pages of the Section concerned.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 11-30-2017, 09:29 PM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

That's a good question as it is, in essence, a header. I do have the 'different first page' option. The only reason I don't have my text boxes in the header itself is that I need the input to be picked up in the table of contents. If I place them within the header, they aren't picked up.
Reply With Quote
  #9  
Old 11-30-2017, 09:31 PM
macropod's Avatar
macropod macropod is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows 7 64bit Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Quote:
Originally Posted by LaurenM View Post
The only reason I don't have my text boxes in the header itself is that I need the input to be picked up in the table of contents. If I place them within the header, they aren't picked up.
I understand that, but what you haven't explained is why you can't achieve the desired outcome the way I suggested.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 11-30-2017, 09:44 PM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

Ah! I see what you mean. That works. Now I just need to figure out how to add the text into that position via VBA.
Reply With Quote
  #11  
Old 11-30-2017, 09:47 PM
macropod's Avatar
macropod macropod is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows 7 64bit Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

If you insert a content control there, or a bookmark, a table cell, textbox, or any other addressable content, that's very straightforward. Obviously, though the details vary according to what addressable content you choose to use.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 11-30-2017, 09:48 PM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

I'll try a table or bookmark as the text boxes keep jumping to the next page
Reply With Quote
  #13  
Old 11-30-2017, 09:54 PM
macropod's Avatar
macropod macropod is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows 7 64bit Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

For a bookmark, you could use:
Code:
ActiveDocument.Bookmarks("BookmarkName").Range.Text = "My Text"
For a Table you could use:
Code:
ActiveDocument.Tables(1).Range.Cells(1).Range.Text = "My Text"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #14  
Old 12-01-2017, 02:07 AM
LaurenM LaurenM is offline Insert Rich Text Content Control in specific position, Word 2013 VBA Windows XP Insert Rich Text Content Control in specific position, Word 2013 VBA Office 2010 32bit
Novice
Insert Rich Text Content Control in specific position, Word 2013 VBA
 
Join Date: Nov 2017
Posts: 14
LaurenM is on a distinguished road
Default

The table works perfectly. Thank you very much!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Rich Text Content Control in specific position, Word 2013 VBA Export Word Drop-Down Content Control to Excel Specific Sheet nolanthomas32 Word VBA 4 09-19-2017 06:25 AM
Insert Rich Text Content Control in specific position, Word 2013 VBA Rich Text Content Control In Template Not Working (Word 2013) irvingdog Word 2 01-26-2017 04:18 PM
Insert Rich Text Content Control in specific position, Word 2013 VBA How do you set rich text in a content control Testor Word VBA 4 07-08-2012 07:55 AM
Insert Rich Text Content Control in specific position, Word 2013 VBA Rich Text Content Control - Allow User Formatting keithacochrane Word 1 05-28-2012 05:06 PM
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 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