Consulting

Results 1 to 3 of 3

Thread: DisplayAlerts is not working in a Word vba script for saving a word documement

  1. #1

    DisplayAlerts is not working in a Word vba script for saving a word documement

    Hi,

    I'm trying to use
    Application.DisplayAlerts = wdAlertsNone
    or
    Application.DisplayAlerts = False
    in my script for avoiding to a have the Word popup message "The document being saved contains track changes Continue with save?" just before to save a word document. But it's not working. The message is still present.

    Here my script:

    Private Sub CreateReportButton_Click()
        Dim objDocA As Word.Document
        Dim objDocB As Word.Document
        Dim objDocC As Word.Document
        
        Dim objFSO As Scripting.FileSystemObject
        Dim objFolderA As Scripting.Folder
        Dim objFolderB As Scripting.Folder
        Dim objFolderC As Scripting.Folder
        
        Dim colFilesA As Scripting.Files
        Dim objFileA As Scripting.File
        
        Dim i As Integer
        Dim j As Integer
        
        Set objFSO = New FileSystemObject
        Set objFolderA = objFSO.GetFolder(ChooseFolder("Choose the folder with the original documents", ThisDocument.Path))
        Set objFolderB = objFSO.GetFolder(ChooseFolder("Choose the folder with revised documents", ThisDocument.Path))
        Set objFolderC = objFSO.GetFolder(ChooseFolder("Choose the folder for the comparisons documents", ThisDocument.Path))
        
        Set colFilesA = objFolderA.Files
        
        For Each objFileA In colFilesA
        If objFileA.Name Like "*.docx" Then
            Set objDocA = Documents.Open(objFolderA.Path & "\" & objFileA.Name)
            Set objDocB = Documents.Open(objFolderB.Path & "\" & objFileA.Name)
            Set objDocC = Application.CompareDocuments( _
                OriginalDocument:=objDocA, _
                RevisedDocument:=objDocB, _
                Destination:=wdCompareDestinationNew)
            objDocA.Close
            objDocB.Close
            On Error Resume Next
            Kill objFolderC.Path & "\" & objFileA.Name
            On Error GoTo 0
            
            'Turn off DisplayAlerts
            Application.DisplayAlerts = wdAlertsNone
            
            objDocC.SaveAs FileName:=objFolderC.Path & "\" & objFileA.Name
            objDocC.Close SaveChanges:=False
        End If
        Next objFileA
        
    End Sub
    Could you please help me to solve the problem?
    Thank you in advance for your help

  2. #2
    Apparently it depends on the version of office, In 2013 it's necessary to go to the Trust Center area of the application (File > Options > Trust Center > Trust Center Settings > Privacy Options) and uncheck the option "Warm before printing, saving or sending a file that contains tracked changes or comments". After doing that files are saved with any message of Word

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    This is a continuation of your CROSS_POSTED discussion in: http://www.vbaexpress.com/forum/show...or-in-a-script. Kindly don't create duplicate threads for the same discussion. Thread closed. You may continue the discussion in the original thread.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •