4
Answers

This command is not available because no document is open.

Photo of Vijay Maurya

Vijay Maurya

9y
1.8k
1
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)

1
Photo of Prasham Sabadra
NA 17.6k 1.2m 8y
Hi Venkat,
Please try this
<script src=”/_layouts/SP.js” type=”text/ecmascript”></script> 
Accepted
1
Photo of Ramesh Palaniappan
NA 13.2k 722.6k 8y
Please add this line to call your function
  1. ExecuteOrDelayUntilScriptLoaded(myjsfucntion,"sp.js");