I have a very simple piece of script which opens a Word doc and sets the header. This works fine. What I cannot identify is how to create a CR between the two elements in the header i.e. line 1 and line 2. Basically I want to do an @NewLine. Can anyone help with the code I need to get this working?
Sample code below.
Set vApp = CreateObject(“Word.Application”) 'Create Word object
vApp.Visible = True
Call vApp.Documents.Add(“K:\work\Example.dot”)
Set wordDoc = vApp.ActiveDocument
With wordDoc.Sections(1).Headers(1).Range
.InsertAfter “Line 1 of Header”
**** what do I need to add here to insert a CR/newline between the two items of text ***
Subject: RE: Simulate @NewLine in Word Object via LS
I don’t know what Word treats as a newline and how it distinguishes between a line break and a paragraph break in OLE, but I usually use this code when I need to use newlines in string constants and make it look tidy:
Try .InsertAfter Chr(13)If this doesn’t work, try Chr(10) or both Chr(10) & Chr(13)
I’ve done this using variables, so it should work with Chr. The only difference in my code was I used parenthesis (e.g., Call range.InsertAfter(Chr(13))