![]() |
#1
|
|||
|
|||
![]()
Hey all,
Attempting to get the bottom portion of this code to work in Excel VBA, I took the language from Word VBA so not sure how well it translates ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument Receiving an error "Runtime error '438': Object doesn't support this property or method" 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 appWD.Visible = True appWD.Selection.WholeStory appWD.Selection.Fields.Update appWD.Selection.Fields.Unlink appWD.ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument appWD.ActiveDocument.Save End Sub Any help is greatly appreciated, thanks, Rich |
#2
|
|||
|
|||
![]()
Changed appWD to "ActiveDocument" on that line and it worked.
Thanks. |
![]() |
Tags |
excel vba, mail merge, word vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word document with VBA and Form Fields reset when select File,Print | fatal.lordes | Word VBA | 9 | 04-27-2018 11:30 PM |
How to update Word 2016 custom mail merge fields in bulk? | dorian | Mail Merge | 1 | 09-23-2017 02:03 AM |
![]() |
CircleG | Word VBA | 6 | 10-17-2014 07:25 PM |
![]() |
Joe Patrick | Word VBA | 2 | 01-30-2012 07:23 AM |
Does Word have an option to update fields AUTOMATICALLY at open??? | Jamal NUMAN | Word | 17 | 01-27-2012 12:57 AM |