|
-
Jul 30th, 2004, 04:09 AM
#1
Thread Starter
Lively Member
Line & Text Box in MS Word
I am trying to us insert a line and a text box in a doc file using VBA. I am able to insert the same but I need help on the following :
1. How to change the width of the line (Eg. Make it thin or fat)
2. How to insert default text (eg. My name) inside the text box.
I am enclosing the code for your reference.
-----------
Private Sub Command1_Click()
Dim oW As Word.Application
Dim oD As Word.Document
Set oW = CreateObject("Word.Application")
oW.Visible = True
Set oD = oW.Documents.Add
oD.Shapes.AddLine 50, 150, 150, 150
oD.Shapes.AddTextbox msoTextOrientationHorizontal, 200, 100, 50, 100
End Sub
-----------
Please help with a code.
-
Jul 30th, 2004, 01:19 PM
#2
Here you go!
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim oW As Word.Application
Dim oD As Word.Document
Dim oS As Word.Shape
Set oW = CreateObject("Word.Application")
oW.Visible = True
Set oD = oW.Documents.Add
Set oS = oD.Shapes.AddLine(50, 150, 150, 150)
oS.Line.Style = msoLineSingle
oS.Line.Weight = 3
Set oS = Nothing
Set oS = oD.Shapes.AddTextbox(msoTextOrientationHorizontal, 200, 100, 50, 100)
oS.TextFrame.TextRange = "Default Text"
Set oS = Nothing
End Sub
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 31st, 2004, 04:02 AM
#3
Thread Starter
Lively Member
-
Jul 31st, 2004, 08:49 PM
#4
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|