Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Macro In Word

  1. #1
    New Member
    Join Date
    Nov 2018
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Macro In Word

    I have this macro in word where i am trying to Merge and turn the files into PDFs. It doesnt seem to be working and i cannot figure out how to go about fixing it. I copied the macro below:


    Code:
    Sub Merge_to_pdf() '
    ' merge1record_at_a_time Macro
    '
    '
        Dim fd As FileDialog
    
    
    
    
        'Create a FileDialog object as a Folder Picker dialog box.
        Set fd = Application.FileDialog(msoFileDialogFolderPicker)
        With fd
    
    
    
    
            'Use the Show method to display the Folder Picker dialog box and return the user's action.
            'The user pressed the button.
            If .Show = -1 Then
                    For Each vrtSelectedItem In .SelectedItems
    
    
    
    
                    'vrtSelectedItem is aString that contains the path of each selected item.
                    'You can use any file I/O functions that you want to work with this path.
                    'This example displays the path in a message box.
            SelectedPath = vrtSelectedItem
    
    
    
    
            Next vrtSelectedItem
    
    
    
    
            Else
            MsgBox ("No Directory Selected.  Exiting")
            Exit Sub
            End If
        End With
    
    
    
    
        'Set the object variable to Nothing.
        Set fd = Nothing
    
    
    
    
    Application.ScreenUpdating = False
    
    
    
    
    MainDoc = ActiveDocument.Name
        ChangeFileOpenDirectory SelectedPath
        For i = 1 To ActiveDocument.MailMerge.DataSource.RecordCount
            With ActiveDocument.MailMerge
                .Destination = wdSendToNewDocument
                .SuppressBlankLines = True
                With .DataSource
                    .FirstRecord = i
                    .LastRecord = i
                    .ActiveRecord = i
                    docName = "2019 Detroit Tigers Spring Training 5 Game Flex Plan Information - " & .DataFields("First_Name").Value & " " & .DataFields("Last_Name").Value & ".pdf"      ' ADDED CODE
                End With
                .Execute Pause:=False
        Application.ScreenUpdating = False
                
            End With
        ActiveDocument.ExportAsFixedFormat OutputFileName:=docName, _
            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
        ActiveWindow.Close SaveChanges:=False
        
    
    
        Next i
    Application.ScreenUpdating = True
    
    
    End Sub


    If anyone can help me out that would be greatly appreciated
    Last edited by Macropod; Dec 6th, 2018 at 05:09 PM. Reason: Added code tags

  2. #2
    Moderator Macropod's Avatar
    Join Date
    Aug 2007
    Location
    Canberra, Australia
    Posts
    2,981
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Macro In Word

    Cheers
    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Member
    Join Date
    Nov 2018
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Macro In Word

    Thank you so much!

    Got it to work with your help it was much appreciated

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
  •