Could you explain:
I have the issue that if I don't add this
.Selection.EndKey Unit:=wdLine
it deletes whats just entered the .selection is writing over it.
"Writing over it"?????
Eeeuuuu. All those .Selection instructions. Bleeech.
All this could be eased if you used Styles.
You have three .TypeParagraph instructions. Lets assume these are "Normal", therefore 12 pts.
You have an Uppercase instruction, a Size instruction, a Bold instruction, an Italics instruction, then inserting text, followed by four more TypeParagraph instructions.
Then, you have a text insertion instruction, a Size instruction, an Italics instruction.
Hmmmm. If this is to be used more than once, use a template with Styles.
I made a style (TekTips1) with a BeforeSpacing = 36 (3 x 12 pts) to match your three TypeParagraphs. It is set for Uppercase, 22 pts, Bold and Italics, with a SpacingAfter = 60 pts (your four .TypeParagraphs), and Centered.
I made a style (TekTips2) as Centered, 12 pts, Bold. Here is your code (partial) using Styles. I removed the Call MakeBorder instruction.
Code:
Sub WithStyle()
Dim objWord As Word.Application
Dim r As Word.Range
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Add Template:="c:\test\tektips.dot"
Set r = objWord.ActiveDocument.Range
With r
.Style = "TekTips1"
.InsertAfter Text:="asbestos survey" & vbCrLf
.Collapse Direction:=wdCollapseEnd
.Style = "TekTips2"
.InsertAfter Text:="performed at"
End With
End With
' destroy objects yadda yadda yadda
End Sub
Note than there is no requirement that the text "abestos survey" has to be in any format, as THAT is covered by the Style.
I printed off two test documents - one using all your Selection.TypeParagraphs, and toggles etc. etc. etc. etc., and one using Styles from a template.
They are identical. Not a single use of Selection.
faq219-2884
Gerry
My paintings and sculpture