I am trying to using Word Automation to save a document to a network drive. I have full access to it. I can even create directories through code on the drive…..
I created a directory on the drive using Directory.CreateDirectory with no problem….. The issue is trying to use Word Automation to save a word document to that created directory.
the file name and path is in this format: \\gy2k3001\Folder1\Folder2\Test.docx
The code I use is this:
Object documentPath=filepath;
wd.ActiveDocument.SaveAs(ref documentPath, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing);
where filepath is equal to @"\\gy2k3001\Folder1\Folder2\Test.docx"
The error I get is this: “This is not a valid file name.\n Try one or more of the following:\n* Check the path to make sure it was typed correctly.\n* Select a file from the list of files and folders.”
What am I doing wrong here? Are you not able to save using network drives in automation?
I can save it fine on my local hard drive….. and like I said before I have all the permissions I need to that network directory
Well…. The problem seemed to be that the server and the wd.ActiveDocument.SaveAs didn’t get along too well… so I ended up saving the document elsewhere and programmatically copying the file to the destination that it needed to go to, instead of SAVING it to the destination directly