Skip to content

Instantly share code, notes, and snippets.

@royashbrook
Created February 25, 2018 13:44
Show Gist options
  • Select an option

  • Save royashbrook/96b430a32b30f6082a568df813b1f800 to your computer and use it in GitHub Desktop.

Select an option

Save royashbrook/96b430a32b30f6082a568df813b1f800 to your computer and use it in GitHub Desktop.
' need tools/references and add a reference to word
Sub InsertDateTime()
' strings to print
Dim t, n, v, delim As String
t = Format(Now(), "YYYY-MM-DD hh:mm:ss") & " EST"
n = "Roy Ashbrook"
delim = " | "
Dim d As Word.Document
Dim s As Word.Selection
Set d = Application.ActiveInspector.WordEditor
Set s = d.Windows(1).Selection
s.GoTo (0)
s.TypeText vbCrLf
s.GoTo (0)
s.Font.ColorIndex = wdBlue
s.Font.Bold = True
s.TypeText t
s.Font.ColorIndex = wdAuto
s.Font.Bold = False
s.TypeText delim
s.Font.ColorIndex = wdRed
s.Font.Bold = True
s.TypeText n
s.Font.ColorIndex = wdAuto
s.Font.Bold = False
s.TypeText delim
Set s = Nothing
Set d = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment