Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Microsoft Word COM object SaveAs raises Command failed

Forum

Search UsersRules
Microsoft Word COM object SaveAs raises Command failed
#1
Active user
Points:: 2
Joined:: Sep 16, 2011

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?

Profile
#2
Active user
Points:: 0
Joined:: Nov 1, 2011

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

Profile
#3
Active user
Points:: 0
Joined:: Nov 1, 2011

Try

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

Profile
#4
Active user
Points:: 2
Joined:: Sep 16, 2011

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.