Word Interop call to SaveCopyAs throws COMException "That method is not available on that object."

Mark Cranness 0 Reputation points
2023-03-08T07:08:55.4233333+00:00

In the Office 2013 Primary Interop Assemblies, the Word interop assembly has a method SaveCopyAs.(This method is not present in the Office 2010 PIAs.)

I need to call this method in a C# VSTO Word add-in, but it fails with a COMException "That method is not available on that object." (HRESULT = 0x800A1704).

I've tried it on a PC with Word 2013 installed, and on another (2) PCs with Word for Microsoft 365 installed, with the same result.

// (Add a reference to Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c)
var wordApplication = (Microsoft.Office.Interop.Word.Application)Marshal.GetActiveObject("Word.Application");
var document = wordApplication.ActiveDocument;
//document.GetType().Assembly.Dump(); // LINQPad
//System.Diagnostics.FileVersionInfo.GetVersionInfo(document.GetType().Assembly.Location).Dump(); // LINQPad
if (string.IsNullOrEmpty(document.Path))
    document.SaveAs("Document must be saved first.docx");
document.SaveCopyAs("Document SaveCopyAs.docx"); // <- this throws

(In case versions matter) At the point of failure, document.GetType().Assembly is Microsoft.Office.Interop.Word.dll (Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c) and has FileVersion=15.0.4603.1000 (installed as part of Microsoft Office 365).

The exception:

Message: That method is not available on that object. 
InnerException: null 
TargetSite.RuntimeMethodInfo: DocumentClass.SaveCopyAs (Object& FileName, Object& FileFormat, Object& LockComments, Object& Password, Object& AddToRecentFiles, Object& WritePasswor... 
StackTrace: 
   at Microsoft.Office.Interop.Word.DocumentClass.SaveCopyAs(Object& FileName, Object& FileFormat, Object& LockComments, Object& Password, Object& AddToRecentFiles, Object& WritePassword, Object& ReadOnlyRecommended, Object& EmbedTrueTypeFonts, Object& SaveNativePictureFormat, Object& SaveFormsData, Object& SaveAsAOCELetter, Object& Encoding, Object& InsertLineBreaks, Object& AllowSubstitutions, Object& LineEnding, Object& AddBiDiMarks, Object& CompatibilityMode)
   at UserQuery 
HelpLink: wdmain11.chm#25372 
Source: Microsoft Word 
HResult: -2146822396 
Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Word | For business | Windows
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.