View Single Post
 
Old 04-13-2025, 08:45 AM
turnsouth turnsouth is offline Windows 11 Office 2021
Novice
 
Join Date: Apr 2025
Posts: 4
turnsouth is on a distinguished road
Default How do I insert a horizontal line at the end of a document?

I've been trying to get this macro to work correctly.

It's for adding a new journal entry. It is suppose to go to the end of the document, insert a horizontal line, and then the date and time.

The date and time work correctly, but for some reason I can only get it to insert the line at the top of the document instead of the end.

I imagine that it has something to do with the range parameter of AddHorizontalLineStandard. But for the life of me, no matter what VBA reference or example I look at, I can not find what the values of 'range" can or is suppose to be.

Thanks,
Paul


Code:
Sub New_Journal_Entry()
'
' Macro2 Macro
'
'
    Selection.EndKey Unit:=wdStory
    ActiveDocument.InlineShapes.AddHorizontalLineStandard
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.InsertDateTime DateTimeFormat:="dddd, MMMM d, yyyy", _
        InsertAsField:=False, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False
    Selection.TypeParagraph
    Selection.InsertDateTime DateTimeFormat:="h:mm am/pm", InsertAsField:= _
        False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
        InsertAsFullWidth:=False
        Selection.TypeParagraph
        Selection.TypeParagraph
End Sub
Reply With Quote