I'm currently working on a solution to:
I have got this working up until i try to save the results as PDF, i get a run-time error '13': Type mismatch.
Heres my code:
--------------
Private Sub OpenWrd()
Application.DisplayAlerts = False
Set wdApp = Word.Application
Set doc = Word.Documents
Set wdApp = CreateObject("Word.Application")
wdApp.Documents.Add ("G:\Everyone\QP12 JSY Maturity Advice.docx")
wdApp.Visible = True
wdApp.WindowState = wdWindowStateMaximize
wdApp.ActiveDocument.MailMerge.OpenDataSource Name:="\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\Save test (sub)\TestSave2.xlsx" _
With wdApp.ActiveDocument.MailMerge
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Dim filename As String
Set myDoc = Word.Documents
Word.Documents.Save "\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\MergeTestSave\TestSave3" & ".pdf"
End Sub
-----------
The code that is highlighted is the
"Word.Documents.Save "\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\MergeTestSave\TestSave3" & ".pdf""
Any clues?
Ta
- Open a specified word document
- Complete a mail merge with specified table in excel
- Save results in '.pdf. format
I have got this working up until i try to save the results as PDF, i get a run-time error '13': Type mismatch.
Heres my code:
--------------
Private Sub OpenWrd()
Application.DisplayAlerts = False
Set wdApp = Word.Application
Set doc = Word.Documents
Set wdApp = CreateObject("Word.Application")
wdApp.Documents.Add ("G:\Everyone\QP12 JSY Maturity Advice.docx")
wdApp.Visible = True
wdApp.WindowState = wdWindowStateMaximize
wdApp.ActiveDocument.MailMerge.OpenDataSource Name:="\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\Save test (sub)\TestSave2.xlsx" _
With wdApp.ActiveDocument.MailMerge
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Dim filename As String
Set myDoc = Word.Documents
Word.Documents.Save "\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\MergeTestSave\TestSave3" & ".pdf"
End Sub
-----------
The code that is highlighted is the
"Word.Documents.Save "\\sbojsyfps001\data\Home\banimb\Data\Documents\BenAdmin\MergeTestSave\TestSave3" & ".pdf""
Any clues?
Ta