none
System.ArgumentException: Value does not fall within the expected range. Microsoft.Office.Interop.Word RRS feed

  • Question

  •  

    I am getting this Error when

    .

    .

    .

    fldTemp.Result.Font = currRange.Font;

    //where currRange is instance of Word.Range

    //and fldTemp is instance of Word.Field ;


    System.ArgumentException: Value does not fall within the expected range.
       at Microsoft.Office.Interop.Word.Range.set_Font(Font prop)
       at xxx.yyy.ThisIsMyFun(args)

    --

    But same code on other machine is executing very well! 
    can any one help, What is missing! SDK/Microsoft interop/or windows update for office

    Thursday, February 20, 2014 1:52 PM

All replies

  • Hi,

    Since your question is related to the office , so I move your question to the office forums.

    Thanks for your understanding.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 21, 2014 6:34 AM
  • Hello Zaffar,

    I have reproduced the issue you described above on my PC with Word 2013 installed. Most probably you are trying to assign the same font. Is this the case?

    As a workaround you can check each property of the Font class and change it if required.

    You may find the How to automate Microsoft Word to create a new document by using Visual C# article helpful.

    • Marked as answer by Marvin_Guo Wednesday, February 26, 2014 2:09 AM
    • Unmarked as answer by Zaffar Mahmood Friday, February 28, 2014 5:39 AM
    Friday, February 21, 2014 8:34 AM
  • thanx Eugene Astafiev for reply,

    but i can not understand this "Most probably you are trying to assign the same font. Is this the case?"

    and what if font is same but other text style (size, bold italic etc) are different!
    and why it is running perfectly on other machine!

    am I using old version of PIA?

    Kind Regards


    Friday, February 28, 2014 5:39 AM
  • Hello Zafar,

    Do you develop a COM add-in or standalone application?

    What version (including the build number) of Word do you have installed on the problematic PC?

    Friday, March 14, 2014 7:10 PM