Results 1 to 2 of 2

Thread: VBA line to automatically click ENTER in script
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Sep 2019
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA line to automatically click ENTER in script

    I have a code that converts documents to PDF format. They are from a mail merge from an excel sheet. When you open the word documents it gives a pop up box and I need it to automatically click ENTER so it will continue. My code is below if anybody has any suggestions
    Code:
    Sub ConvertWordsToPdfs()
    'Updated by Extendoffice 20181123
        Dim xIndex As String
        Dim xDlg As FileDialog
        Dim xFolder As Variant
        Dim xNewName As String
        Dim xFileName As String
        Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
        If xDlg.Show <> -1 Then Exit Sub
        xFolder = xDlg.SelectedItems(1) + "\"
        xFileName = Dir(xFolder & "*.*", vbNormal)
        While xFileName <> ""
            If ((Right(xFileName, 4)) <> ".doc" Or Right(xFileName, 4) <> ".docx") Then
                xIndex = InStr(xFileName, ".") + 1
                xNewName = Replace(xFileName, Mid(xFileName, xIndex), "pdf")
                Documents.Open FileName:=xFolder & xFileName, _
                    ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
                    PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
                    WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
                    wdOpenFormatAuto, XMLTransform:=""
                ActiveDocument.ExportAsFixedFormat OutputFileName:=xFolder & xNewName, _
                    ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
                    wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
                    Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
                    CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
                    BitmapMissingFonts:=True, UseISO19005_1:=False
                ActiveDocument.Close
            End If
            xFileName = Dir()
        Wend
    End Sub

  2. #2
    New Member
    Join Date
    Jun 2019
    Posts
    48
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA line to automatically click ENTER in script

    Does
    Code:
    Application.DisplayAlerts = False
    not work?

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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