Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MailMerge Error

Status
Not open for further replies.

halfbarrel

Programmer
Jun 12, 2002
44
US
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
 
Hallo,

I know it's a bit basic, but have you tried stopping on the red line, opening Word and pasting your filespec into the File->Open dialog and making sure it opens ok?

- Frink
 
Frink,
I gave that a try, and it opened fine. To get the path originally I had went into the file properties and copied it. So there's no problem there. One thing that I did notice is that if I run the form that runs my mailmerge code by double clicking on the form it runs through fine. If I try to run it from the Scheduled Tasks program within windows I get the error mentioned above. Thanks, for you response let me know if you have any more ideas.

Chris.
 
Hallo,

I'm afraid that's all I can think of.
I've not got Windows 2000, but are there any permissions that you need to set up, like on the file you are trying to open, and each of the folders back up to the drive letter.
It seems to me that your scheduler is running with fewer permissions than your user account.

Sorry I can't help any more,

- Frink
 
Fink,
I figured it out. You were on the right track. The user that I had scheduled the task with was a power user I switched that to an administrative login that we have and it works fine. It's kind of goofy that when I was logged in as that power user I could run that mailmerge code fine, but with the task scheduled as that user it would blow up. Thanks for helping me think this one out.
Thanks,

Chris.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top