Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. the command is not available because no document is open

the command is not available because no document is open

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethtmlcomhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vimalkumarsinghal
    wrote on last edited by
    #1

    hi guys i m using asp.net an C# im trying to convert .docx to html when i use my machine documents open and also easily converted to html,,my machine have (xp sp2,visual studio2008,MS Office 2007) when i go for client pc when i click convert button i m getting error like this "the command is not available because no document is open"

    Microsoft.Office.Interop.Word.ApplicationClass wordApplication = new ApplicationClass();
    object o_nullobject = System.Reflection.Missing.Value;
    String strfiletoupload = @"C:\inetpub\wwwroot\wss\VirtualDirectories\12122\uploaded\template\DeveloperEmail.docx";
    object o_filePath = strfiletoupload;
    Microsoft.Office.Interop.Word.Document doc = wordApplication.Documents.Open(ref o_filePath,
    ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
    ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
    ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject);
    object o_newfilename = @"C:\inetpub\wwwroot\wss\VirtualDirectories\12122\uploaded\template\NewsletterEmail.html";
    object o_format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatFilteredHTML;
    //object o_format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
    object o_encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
    object o_endings = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
    //Microsoft.Office.Interop.Word.wd
    object o_BiDiMark = true;

                      wordApplication.ActiveDocument.SaveAs(ref o\_newfilename, ref o\_format, ref o\_nullobject,
                              ref o\_nullobject, ref o\_nullobject, ref o\_nullobject, ref o\_nullobject, ref o\_BiDiMark,
                              ref o\_BiDiMark,
                          ref o\_nullobject, ref o\_nullobject, ref o\_encoding, ref o\_nullobject,
                              ref o\_nullobject, ref o\_endings, ref o\_BiDiMark);
                      doc.Close(ref o\_nullobject, ref o\_nullobject, ref o\_nullobject);
    
                      wordApplication.Quit(ref o\_nullobject, ref o\_nullobject, ref o\_nullobject);
                      System.Runtime.InteropServ
    
    N 1 Reply Last reply
    0
    • V vimalkumarsinghal

      hi guys i m using asp.net an C# im trying to convert .docx to html when i use my machine documents open and also easily converted to html,,my machine have (xp sp2,visual studio2008,MS Office 2007) when i go for client pc when i click convert button i m getting error like this "the command is not available because no document is open"

      Microsoft.Office.Interop.Word.ApplicationClass wordApplication = new ApplicationClass();
      object o_nullobject = System.Reflection.Missing.Value;
      String strfiletoupload = @"C:\inetpub\wwwroot\wss\VirtualDirectories\12122\uploaded\template\DeveloperEmail.docx";
      object o_filePath = strfiletoupload;
      Microsoft.Office.Interop.Word.Document doc = wordApplication.Documents.Open(ref o_filePath,
      ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
      ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject,
      ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject, ref o_nullobject);
      object o_newfilename = @"C:\inetpub\wwwroot\wss\VirtualDirectories\12122\uploaded\template\NewsletterEmail.html";
      object o_format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatFilteredHTML;
      //object o_format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
      object o_encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
      object o_endings = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
      //Microsoft.Office.Interop.Word.wd
      object o_BiDiMark = true;

                        wordApplication.ActiveDocument.SaveAs(ref o\_newfilename, ref o\_format, ref o\_nullobject,
                                ref o\_nullobject, ref o\_nullobject, ref o\_nullobject, ref o\_nullobject, ref o\_BiDiMark,
                                ref o\_BiDiMark,
                            ref o\_nullobject, ref o\_nullobject, ref o\_encoding, ref o\_nullobject,
                                ref o\_nullobject, ref o\_endings, ref o\_BiDiMark);
                        doc.Close(ref o\_nullobject, ref o\_nullobject, ref o\_nullobject);
      
                        wordApplication.Quit(ref o\_nullobject, ref o\_nullobject, ref o\_nullobject);
                        System.Runtime.InteropServ
      
      N Offline
      N Offline
      Nasri87
      wrote on last edited by
      #2

      Hi vimal, try these links, mayb helpful for u. http://msdn.microsoft.com/en-us/magazine/cc163526.aspx.[^] HTML to WordML[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups