View Single Post
 
Old 10-12-2014, 09:15 AM
Charles Kenyon Charles Kenyon is offline Windows 7 64bit Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,464
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I don't know that it is possible to completely eliminate it. However, the following code sets the default when you add a field through Insert>Quick Parts>Fields is to have the box to insert it uinchecked.

I have it installed in an Add-In.
Code:
Sub InsertField()
'   Graham Mayor vba samples
'   Intercepts InsertField command and removes MERGEFORMAT default
'   Allows CHARFORMAT switch option
'
    Dim oRng As Range, i As Variant, sSwitch As String, strChoice As String
    '
    ' Uncheck box to insert MERGEFORMAT
    '
    SendKeys "{Tab 2} +{Tab 2}"
    '
    Dialogs(wdDialogInsertField).Show
    On Error GoTo Finish 'User has cancelled
    '
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    Set oRng = Selection.Range
    '
    For i = 1 To oRng.Fields.Count
        With oRng.Fields(i)
            If InStr(1, .Code, "MERGEFORMAT") <> 0 Then
                sSwitch = MsgBox("Use charformat in place of the mergeformat switch?", _
                vbYesNo, _
                "Insert Field")
                If sSwitch = vbYes Then
                    .Code.Text = Replace(.Code.Text, _
                    "MERGEFORMAT", _
                    "CHARFORMAT")
                End If
            End If
            .Update
        End With
    Next i
    Selection.MoveRight Unit:=wdCharacter, Count:=1
Finish:
End Sub

If you do check the box, it asks if you want CharFormat instead.
Reply With Quote