View Single Post
 
Old 04-13-2025, 11:58 AM
Italophile Italophile is offline Windows 11 Office 2021
Expert
 
Join Date: Mar 2022
Posts: 554
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Instead of adding a shape and a bunch of empty paragraphs it would be better to create two new styles - Journal Date with a top border set above the paragraph by a suitable distance (20pts in the screenshot) and a suitable space before (12pt in the screenshot), and Journal Date with a suitable space after (12pt in the screenshot).

Screenshot 2025-04-13 195654.png

Your code can then be:
Code:
Sub NewJournalEntry()
    With ActiveDocument.Paragraphs
        With .Last.Range
            'ensure that there is an empty paragraph at the end of the document
            .InsertParagraphAfter
        End With
        With .Last.Range
            .InsertDateTime DateTimeFormat:="dddd, MMMM d, yyyy", _
                InsertAsField:=False, DateLanguage:=wdEnglishUS, CalendarType:= _
                wdCalendarWestern, InsertAsFullWidth:=False
            .Style = "Journal Date"
        End With
        .Last.Range.InsertParagraphAfter
        With .Last.Range
            .InsertDateTime DateTimeFormat:="h:mm am/pm", InsertAsField:= _
                False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
                InsertAsFullWidth:=False
            .Style = "Journal Time"
        End With
        .Last.Range.InsertParagraphAfter
        .Last.Style = wdStyleNormal
    End With
    
End Sub
Reply With Quote