Microsoft Word COM object SaveAs raises Command failed

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 6
Joined: Sep 16, 2011
Company:

I'm trying to write a document at server, but it falls with an exception. Here is the source:

Code
ActiveDocument = Object.Ref.GetObject().GetTemplate("Report");
ComObject = ActiveDocument.Get();
WordDocument = ComObject.Application.Documents(1);
WordDocument.Activate();
FillReport(WordDocument);
TempFile = "c:\temp.doc";
WordDocument.SaveAs(TempFile);

It works fine when executed at client, but falls with the following exception at server:

{Catalog.Reports.Form.Form.Form (153)}: Error calling context method (SaveAs)
  WordDocument.SaveAs(TempFile);
reason:
An exception has occurred (Microsoft Word): Command failed

Any ideas?

Edited: Xin Wang - Aug 07, 2012 03:06 PM
 
#2
People who like this:1Yes/0No
Active user
Rating: 3
Joined: Nov 1, 2011
Company:

May be user which runs server don't have rights to write on C:\

 
#3
People who like this:1Yes/0No
Active user
Rating: 3
Joined: Nov 1, 2011
Company:

Try

Code
WordDocument.SaveAs(TempFilesDir()+"temp.doc");

 
#4
People who like this:0Yes/0No
Active user
Rating: 6
Joined: Sep 16, 2011
Company:

Thank you, Alexey! Both are correct, I changed the directory for saving files and set access for user which runs 1C:Enterprise server.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.