Vijay Maurya

Vijay Maurya

  • NA
  • 4
  • 6.9k

This command is not available because no document is open.

Jun 29 2015 2:36 AM
Some body help me 
I got error when we use below code [i m doing .docx to ,htm file coversion meas save file .docx to .htm]
 
 Code is-
Microsoft.Office.Interop.Word.Application app;
app.Documents.Open(ref FileName, ref readOnly, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing,
ref missing, ref missing);
Document oDoc = app.ActiveDocument;
oDoc.SaveAs(ref FileToSave, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing);
 
Error is- 

This command is not available because no document is open.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: This command is not available because no document is open.

Source Error:

 Document oDoc = app.ActiveDocument;           
 

Answers (4)