Visual Basic.NET
--
Questions
--
Followers
Top Experts
Dim oWord As Object
Dim oDoc As Object
Dim oPara1 As Object, oPara2 As Object
Dim strText As String
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
oDoc.Activate()
' Attempt #1
With oWord.Selection
.Font.Size = 24
.Font.Bold = True
.TypeText("2009 Call Report")
.Borders.Item(wdBorderBottom).LineStyle = wdLineStyleSingle
.Font.Size = 12
.Font.Bold = False
.TypeParagraph()
.Font.Color = wdColorRed
.Font.Italic = False
.TypeText("This sentence will appear in red. ")
.TypeParagraph()
.Font.Color = wdColorBlack
.Font.Italic = True
.Font.Size = .Font.Size + 2
.TypeText("Text color was reset to black, " & _
"but the font size was increased by two points.")
End With
' Attempt #2
oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "2009 Call Reports"
oPara1.Range.Font.Bold = True
oPara1.Range.Borders.Item(wdBorderBottom).LineStyle = wdLineStyleSingle
oPara1.Format.SpaceAfter = 24 '24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter()
oPara2 = oDoc.Content.Paragraphs.Add
oPara2.Range.Text = "Salesperson: "
oPara2.Range.Font.Bold = True
oPara2.Range.Font.Color = wdColorRed
oPara2.Format.SpaceAfter = 14
oPara2.Range.InsertParagraphAfter()
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
With Selection.ParagraphFormat
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
End With
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With
.TypeText("2009 Call Report")
.Borders.Item(wdBorderBott
.InsertBreak(wdSectionBrea
.Borders(wdBorderBottom).L
.TypeText("Text without border.")






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Chris
Sub addBorder()
Dim bord As Variant
With ThisDocument.Paragraphs(1)
For Each bord In Array(wdBorderLeft, wdBorderRight, wdBorderTop, wdBorderBottom)
With .Borders(bord)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
End With
Next
End With
End Sub
Chris
Sub addBorder()
Dim bord As Variant
With ThisDocument.Paragraphs(1)
For Each bord In Array(wdBorderLeft, wdBorderRight, wdBorderTop, wdBorderBottom)
With .Borders(bord)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders
.DistanceFromTop = 1
.DistanceFromLeft = 4
.DistanceFromBottom = 1
.DistanceFromRight = 4
.Shadow = False
End With
Next
End With
End Sub
Chris

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
And I'll be sure to keep an eye out for future questions from you wellhole....

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Visual Basic.NET
--
Questions
--
Followers
Top Experts
Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,