One of the values passed to this method or property is out of range - Range.ExportFragment issue with word 2010 vsto plugin RRS feed

  • Question

  • I am trying to export a part of the document of the word to html on VSTO plugins using below method :

    Word.Selection selectedWord = Globals.ThisAddIn.Application.Selection;
    var tempFilename = "c://Test.html";
    selectedWord.Range.ExportFragment(tempFilename, Word.WdSaveFormat.wdFormatHTML);

    this code is working fine in word 2013 and above but when i tried to run this code in word 2010 vsto it is giving us following exception:

    One of the values passed to this method or property is out of range. **Stack Trace:    at Microsoft.Office.Interop.Word.Range.ExportFragment(String FileName, WdSaveFormat Format)

    at initial I thought maybe word 2010 VSTO does not support 


     but when I tried to save the document it is showing an option to save as HTML.

    Can anyone please help.

    • Edited by aschauhan29 Thursday, October 22, 2020 1:38 PM Code formatted
    Thursday, October 22, 2020 1:36 PM

All replies

  • Try to specify another location or local disk. The system drive may require admin privileges for writing.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Thursday, October 22, 2020 8:29 PM
  • I have tried by running word as administrator but still no luck. So permission might not be the problem.

    Friday, October 23, 2020 4:48 AM