Excel: Duplicate open word document before making changes - VBA


Hi everyone! I’m trying to finish off a sub routine but I’m facing a small issue. The code tries to open a given file (word template) through a dialog box. However I need to duplicate this Word document so that I do not lost the initial template. I would simply like to have the code applied to the duplicate and not the initial template. Below is the code: ----------------------------------------------------------------- Sub report() Application.DisplayAlerts = False Application.ScreenUpdating = False Dim WordApp As Word.Application Dim report As Word.Document Dim FileToOpen As Variant Set WordApp = CreateObject("Word.Application") WordApp.Visible = True FileToOpen = Application.GetOpenFilename(Title:="Please select a Word file to open", FileFilter:="Word Files (*.doc;*.docx),*.doc;*.docx") If FileToOpen = False Then MsgBox "No File selected!" Exit Sub Else Set report = WordApp.Documents.Open(FileToOpen) End If 'Code to duplicate the file should be placed here????? Application.ThisWorkbook.Sheets(2).ChartObjects("Chart 1").Copy report.Bookmarks("Chart1").Range.Paste Application.ThisWorkbook.Sheets(2).ChartObjects("Chart 2").Copy report.Bookmarks("Chart2").Range.Paste Application.ThisWorkbook.Sheets(2).ChartObjects("Chart 8").Copy report.Bookmarks("Chart3").Range.Paste Application.ThisWorkbook.Sheets(2).ChartObjects("Chart 11").Copy report.Bookmarks("Chart4").Range.Paste Application.ThisWorkbook.Sheets(2).ChartObjects("Chart 9").Copy report.Bookmarks("Chart5").Range.Paste Application.ThisWorkbook.Sheets(2).Range("Table1[#All]").Copy report.Bookmarks("Table1").Range.PasteSpecial xlPasteValues report.Tables(1).AutoFitBehavior wdAutoFitWindow report.TablesOfContents(1).update Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub ---------------------------------------------------------------------------------------------------------------- Any thoughts? Thanks in advance


This question generated 11 answers. To proceed to the answers, click here.

This thread is current as of April 18, 2015.


For more resources for Microsoft Excel