Thread: [Solved] Use of Range Object Question
View Single Post
 
Old 08-14-2012, 04:07 PM
jsb73 jsb73 is offline Windows 7 32bit Office 2007
Novice
 
Join Date: Aug 2012
Posts: 4
jsb73 is on a distinguished road
Default

Thanks Paul,

In the following code, how is the optimal way to add another paragraph to the document using the Range object if that is the most efficient way?

Code:
Dim wo As Word.Application
    Set wo = CreateObject("Word.Application")
    Dim woDoc As Word.Document
    Dim woRng As Word.Range
    
    With wo
        .WindowState = wdWindowStateMaximize
        .Documents.Add
        Set woDoc = wo.ActiveDocument
        Set woRng = woDoc.Range
        With woRng
            .Font.Bold = True
            .Font.Size = 12
            .Paragraphs.Alignment = wdAlignParagraphCenter
            .InsertAfter "Hello Ranger Again"
        End With
    End With
   
    ActiveDocument.SaveAs "C:\LookingAtWord\Ranger.doc"
    wo.Visible = True

Last edited by macropod; 08-14-2012 at 04:15 PM. Reason: Added code tags & formatting
Reply With Quote