Paste Horizontal Line (Rich Text)

MACRO: Paste Horizontal Line (Rich Text)

VER: 3.0 2016-05-17 ~~~~~
2016-05-31 15:35 CT (Tue)


Paste Horizontal Line (Rich Text).kmmacros (39 KB)
[KM] DELETE List of KM Variables [SUB-MACRO].kmmacros (14 KB)

Major Changes

• Now supports MS Word, TextEdit, Evernote, Outlook 2011
• NEED SCRIPT for Apple Pages

Author: @JMichaelTX

PURPOSE: Paste a Horizontal Line in any Rich Text App
• Approach/Method Changes based on App
• Now supports MS Word, TextEdit, Evernote, Outlook 2011
• NEED SCRIPT for Apple Pages

(1) See Setup Instructions in below Comments for each app

(1) In any Rich Text app, position cursor on a blank line where you want the horiz. line
(2) Run this macro.

(1) Keyboard Maestro Ver 7.0.3+
(2) Yosemite (10.10.5)+
(3) Safari (only for setup)
(4) KM Macro: [KM] DELETE List of KM Variables [SUB-MACRO]


1 Like

###Horizontal Line for Apple Pages and Microsoft Word

The above macro probably will not work in either Pages or Word.

Here is how to create a horizontal line/rule in those apps, using the app’s native tools:

  1. Pages for Mac: Add borders and rules (lines)
  2. Microsoft Word
  • Place your cursor in the paragraph (but do not select any text) for which you want the line/rule to appear below
  • then select Format > Borders and Shadings
  • insert a “line below” the paragraph
    (use the “Apply to: Paragraph” dropdown).
  • This line is integral to the paragraph and the separation to the text above it can be controlled in the dialog (the Options button) or dragged vertically in the document.

I’m sure you could automate this using a KM macro, and use the appropriate method based on the frontmost app.

###MS Word VBA Macro to Apply Horizontal Line

You can add this VBA macro to your MS Word Normal template, and it will be available to ALL documents. You can assign a Word shortcut key to it, or execute the VBA macro from AppleScript, which you could embed in a KM macro.

Sub Horizontal_Line()
' Horizontal_Line Macro
    With Selection.ParagraphFormat
        .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
        .Borders(wdBorderRight).LineStyle = wdLineStyleNone
        .Borders(wdBorderTop).LineStyle = wdLineStyleNone
        With .Borders(wdBorderBottom)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth050pt
            .Color = wdColorAutomatic
        End With
        With .Borders
            .DistanceFromTop = 1
            .DistanceFromLeft = 4
            .DistanceFromBottom = 3
            .DistanceFromRight = 4
            .Shadow = False
        End With
    End With
    With Options
        .DefaultBorderLineStyle = wdLineStyleSingle
        .DefaultBorderLineWidth = wdLineWidth050pt
        .DefaultBorderColor = wdColorAutomatic
    End With
End Sub

It doesn’t work with Evernote, either. :disappointed:

Evernote already has a feature to insert horizontal line. Just exclude Evernote from the apps available for the group you put this macro in.

Having said that, I have new version I am testing that will handle Evernote and other apps. Stay tuned. :smile:

I’m looking forward to trying that new version. I want it for Evernote because I use KM to append and prepend data to notes in EN, and I much prefer to have KM insert a horizontal rule than a string of hyphens between them.

In EN Mac, you can insert a horizontal line by:
Goto menu Format > Insert Horizontal Rule ⇧⌘H

I had been using Paste by Typing to include named clipboard contents and the horizontal rule. It was so simple that I could omit the horizontal rule from there, switch to EN, and send a the keyboard command, that I missed it. Thanks for pointing it out to me. I’m much happier with my EN macros now!

Just updated the macro in my OP at the top.

Update published. It will now handle Evernote (it just uses the EN Mac native menu).