halfbarrel
Programmer
Hey,
I'm wondering if someone can help me out with an error I'm getting trying to automate a mailmerge. The line I'm getting the error on is bolded in red bellow. The error I'm getting is error #70 Permission Denied. I am trying to automate this by running it from scheduled tasks on a Windows 2000 server. I do have Microsoft Word 9.0 Object library and OLE Automation referenced. Please let me know if you can offer any assistance.
Thanks,
Chris
Dim name As Variant
Dim objWord As New Word.Application
Dim objDoc As Word.Document
Set objDoc = objWord.Documents.Open("D:\dbsync\unapplied\Reports\Stored Reports\SENTSOF\LBLSENTSOF.doc"
objWord.Application.Visible = True
'create a name for the new document
name = "D:\dbsync\unapplied\Reports\Stored Reports\SENTSOF\SENTSOF.doc"
objDoc.MailMerge.Destination = wdSentToNewDocument
objDoc.MailMerge.Execute
objWord.Application.Documents(1).SaveAs FileName:=name
objWord.Application.Documents(1).Close wdDoNotSaveChanges
objWord.Application.Documents(1).Close wdDoNotSaveChanges
objWord.Quit
Set objDoc = Nothing 'destroy object
Set objWord = Nothing 'destroy object
I'm wondering if someone can help me out with an error I'm getting trying to automate a mailmerge. The line I'm getting the error on is bolded in red bellow. The error I'm getting is error #70 Permission Denied. I am trying to automate this by running it from scheduled tasks on a Windows 2000 server. I do have Microsoft Word 9.0 Object library and OLE Automation referenced. Please let me know if you can offer any assistance.
Thanks,
Chris
Dim name As Variant
Dim objWord As New Word.Application
Dim objDoc As Word.Document
Set objDoc = objWord.Documents.Open("D:\dbsync\unapplied\Reports\Stored Reports\SENTSOF\LBLSENTSOF.doc"
objWord.Application.Visible = True
'create a name for the new document
name = "D:\dbsync\unapplied\Reports\Stored Reports\SENTSOF\SENTSOF.doc"
objDoc.MailMerge.Destination = wdSentToNewDocument
objDoc.MailMerge.Execute
objWord.Application.Documents(1).SaveAs FileName:=name
objWord.Application.Documents(1).Close wdDoNotSaveChanges
objWord.Application.Documents(1).Close wdDoNotSaveChanges
objWord.Quit
Set objDoc = Nothing 'destroy object
Set objWord = Nothing 'destroy object