c# - This command is not available because no document is open while getting Active document -


try {      microsoft.office.interop.word.application wordobj = system.runtime.interopservices.marshal.getactiveobject("word.application") microsoft.office.interop.word.application;      office.customxmlparts currclassification = wordobj.activedocument.customxmlparts; } catch(exception ex) {      //i getting, command not available because no document open. error here. } 

when using above code, getting error:

this command not available because no document open.

regards

actually trying access active document when there no document open in word application getting error. word application open no document opened in i.e. @ home screen of word application shown in image.

enter image description here

try use following code check whether there open documents in application , access activedocument

if(wordobj.documents.count >= 1) 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -