Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-31-2017, 12:41 PM
gmaxey gmaxey is offline Create text box in VBA and style content Windows 7 32bit Create text box in VBA and style content Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 7/31/2017
Dim oShp_TB As Shape
  '1.
  Set oShp_TB = ActiveDocument.Shapes.AddTextbox( _
        Orientation:=msoTextOrientationHorizontal, _
        Left:=50, Top:=50, Width:=100, Height:=100)
  With oShp_TB
     With .TextFrame.TextRange
      '2.
      .Text = "This is some text"
      '3.
      .Font.Name = "Calibri"
      .Font.Size = 8
      .Font.ColorIndex = wdBlue
      .ParagraphFormat.Alignment = wdAlignParagraphCenter
      'Or use a defined style
      '.Style = "My TextBox Style"
    End With
    '4.
    With .Line
      .Weight = 2
      .ForeColor = wdColorRed
    End With
    '5.
    .Left = 200
    .Top = 300
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
style, textbox, vba in microsoft word

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create text box in VBA and style content Rich Text Content Contol retain Style Setting when whole document is changed ciresuark Word 1 02-22-2016 06:25 PM
Macro to create a title in the Header when a certain text style is used (such as Heading 1) Lonesy Word VBA 1 06-03-2015 03:57 AM
Create text box in VBA and style content I create a new style but it fails to appear in Quick Style list veronius Word 6 06-18-2013 06:29 PM
Matching text style to drawing object style notarichman PowerPoint 0 03-07-2011 11:34 AM
How to create macro to paste text after style? Srivas Word 0 03-16-2010 05:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:36 AM.


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