UndoRecord.IsRecordingCustomRecord=False, After Export or import Fragment RRS feed

  • Question

  • I want to group some word operations into a undo Record (unit).  

    (1) UndoRecord.IsRecordingCustomRecord=True

    (2) But after using Range.ExportFragment() or Range.ImportFragment() 

    (3) UndoRecord.IsRecordingCustomRecord=False

    How to configure or set Word can support (remember) the Undo list.

    XBRL Expert

    Tuesday, September 5, 2017 4:28 AM

All replies

  • Hello,

    I test the following code and when ImportFragment, the IsRecordingCustomRecord would be true. When ExportFragment, the IsRecordingCustomRecord would be false.

    Sub test()
    Dim objUndo As UndoRecord
    Set objUndo = Application.UndoRecord
    If objUndo.IsRecordingCustomRecord = False Then
    CreateUndoRecord ("My Custom Undo")
    End If
    'Selection.Range.ExportFragment "D:\Doc2.docx", wdFormatDocumentDefault
    'Debug.Print objUndo.IsRecordingCustomRecord
    Selection.Range.ImportFragment "D:\Doc1.docx"
    Debug.Print objUndo.IsRecordingCustomRecord
    End Sub
    Sub CreateUndoRecord(urName As String)
        ' Create a new undo record and insert some text.
        Dim ur As UndoRecord
        Set ur = Application.UndoRecord
        ur.StartCustomRecord urName
        ActiveDocument.Range.InsertAfter urName & " started."
        Debug.Print ur.IsRecordingCustomRecord
    End Sub

    I think this is expected result. We are unable to undo the Export, so UndoRecord.IsRecordingCustomRecord=false after exporting. If you want to undo Range.ExportFragment() , you may delete the file using Kill function.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, September 6, 2017 7:16 AM