View Single Post
 
Old 10-29-2016, 02:44 AM
trent.bourne trent.bourne is offline Windows 10 Office 2013
Novice
 
Join Date: Oct 2016
Posts: 1
trent.bourne is on a distinguished road
Exclamation Change Macro so it does not refer to "Active Document"

Hey Guys,

I need help changing this macro so that it runs in the background and does not chuck out an error as the document opens in the background.

I would prefer if I could add some code to bring the document to the front.

The code is

PHP Code:
Private Sub Document_Open()



'   Show mail merged folders.. not as <<id>>

    ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False





Save the file as an PDF File



    ActiveDocument
.Save

    ActiveDocument
.ExportAsFixedFormat OutputFileName:= _

        
"D:\Users\tmb842\Documents\VMPD\Compleated Documents (Mail Merge Finals)\VMPD - Practice First Contact - GP  Dentists.pdf" _

        
ExportFormat:=wdExportFormatPDFOpenAfterExport:=FalseOptimizeFor:= _

        wdExportOptimizeForPrint
Range:=wdExportAllDocumentFrom:=1To:=1_

        Item
:=wdExportDocumentContentIncludeDocProps:=TrueKeepIRM:=True_

        CreateBookmarks
:=wdExportCreateNoBookmarksDocStructureTags:=True_

        BitmapMissingFonts
:=TrueUseISO19005_1:=False

        

    ActiveDocument
.Close

    

 

End Sub 
Reply With Quote