I'm trying to active a Word document to reference it as the 'ActiveDocument', however i am facing an "Expected end of Statement" error.
Here's the code:
Anyone got any ideas?
Thanks
Here's the code:
Code:
Private Sub OpenWrd()
Dim wdApp As Word.Application, MyDoc As Word.Document
Dim objWord As New Word.Application
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
wdApp.WindowState = wdWindowStateMaximize
Set MyDoc = wdApp.Documents.Add("G:\Everyone\QP12 JSY Maturity Advice.docx")
With MyDoc
With .MailMerge
.OpenDataSource Name:="\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\Save test (sub)\TestSave2.xlsx"
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
wdDocument: FileName"Form Letters1".Activate
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\MergeTestSave\Standard Bank Jersey LimitedTest.pdf" _
, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
ChangeFileOpenDirectory _
"\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\MergeTestSave\"
End With
End Sub
Anyone got any ideas?
Thanks
Last edited by a moderator: