Thread: [Solved] Is this possible to create?
View Single Post
 
Old 04-27-2018, 01:18 PM
RMerckling RMerckling is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Jan 2018
Posts: 29
RMerckling is on a distinguished road
Default Figured it out.

Code:
Sub CopyandRename()
    Dim str1 As String
    str1 = "Q:\IC\New Structure\IC Toolkit\Templates\01 Plan Doc Template\16 Source\IC Plan Doc Template v1.0.docx"
    PlanDocTemplate = Application.ActiveWorkbook.Path & "\" & Range("A1").Value & ".docx"
    
    Call FileCopy(str1, PlanDocTemplate)
    
    strWorkbookName = ThisWorkbook.Path & "\" & ThisWorkbook.Name
    Worksheets("Data").Activate
       
'Opens New Plan Doc Template

    Set appWD = CreateObject("Word.Application")
    appWD.Visible = True

    appWD.Documents.Open Filename:=PlanDocTemplate
    
    ActiveDocument.MailMerge.OpenDataSource Name:=strWorkbookName, _
    Format:=wdMergeInfoFromExcelDDE, _
    ConfirmConversions:=True, _
    ReadOnly:=False, _
    LinkToSource:=True, _
    AddtoRecentFiles:=False, _
    PasswordDocument:="", _
    PasswordTemplate:="", _
    Revert:=False, _
    Connection:="Entire Spreadsheet", _
    SQLStatement:="SELECT * FROM `Data$`", _
    SQLStatement1:="", _
    SubType:=wdMergeSubTypeOther
End Sub
Reply With Quote