View Single Post
 
Old 07-21-2016, 11:47 PM
neoported neoported is offline Windows 10 Office 2013
Novice
 
Join Date: Jul 2016
Posts: 2
neoported is on a distinguished road
Default

Excellent, thanks for the pointers

The macro I'm currently using is

Code:
 
'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    Dim WinUsername     As String
'Replace the text @@WinUsername@@ with the environment variable username
    ActiveWindow.View.ShowFieldCodes = True
    WinUsername = Environ("Username")
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "@@WinUsername@@"
        .Replacement.Text = WinUsername
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ActiveWindow.View.ShowFieldCodes = False
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Just need to tinker with that now to join your code to it. I'm sure I'll get there in the end
Reply With Quote