none
COMException trying to add a field RRS feed

  • Question

  • Hi all;

    Another one of those lovely errors without a whole lot of information. One of our customers, one one system only, is consistently getting a COMException with the message "This command is not available" when we call Microsoft.Office.Interop.Word.Fields.Add(Range, Type, Text, PreserveFormatting).

    Any idea why?

    thanks - dave


    Very funny video - What's your Metaphor?
    Thursday, December 30, 2010 3:22 PM

Answers

  • Hi Dave

    But you do know the versions of Word and Office involved? That always helps - honest :-)

    The error message indicates the Selection (or target Range) is somewhere that won't allow field insertion. So please make sure that the user has, for example, a blinking cursor in the "plain text" of the document and no where else. If the message is still occurring...

    Whenever I get a "only one person" type of error, the first thing that occurs to me is that there's something wrong with the configuration. Then there's a whole list of trouble-shooting steps to go through, starting with...

    Quit Word. Rename Normal.dot(m) to Normal.old and start Word again. (This generates a "clean copy"). Create a new document and test the code.

     


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by DavidThi808 Thursday, December 30, 2010 9:20 PM
    Thursday, December 30, 2010 3:50 PM
    Moderator

All replies

  • Hi Dave

    But you do know the versions of Word and Office involved? That always helps - honest :-)

    The error message indicates the Selection (or target Range) is somewhere that won't allow field insertion. So please make sure that the user has, for example, a blinking cursor in the "plain text" of the document and no where else. If the message is still occurring...

    Whenever I get a "only one person" type of error, the first thing that occurs to me is that there's something wrong with the configuration. Then there's a whole list of trouble-shooting steps to go through, starting with...

    Quit Word. Rename Normal.dot(m) to Normal.old and start Word again. (This generates a "clean copy"). Create a new document and test the code.

     


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by DavidThi808 Thursday, December 30, 2010 9:20 PM
    Thursday, December 30, 2010 3:50 PM
    Moderator
  • Hi;

    It's Word 2007. Very good idea on deleting Normal.dot - I'll have him try that.

    thanks - dave


    Very funny video - What's your Metaphor?
    Thursday, December 30, 2010 4:13 PM
  • Hi Dave

    Not delete - RENAME! Otherwise you could lose the user's customizations (macros, AutoText, etc.)


    Cindy Meister, VSTO/Word MVP
    Thursday, December 30, 2010 4:35 PM
    Moderator
  • We test and don't allow it, but somehow he managed to get the caret right after a table and tried to force a field insert there. No matter how much you try, users will always find a way...

    thanks - dave


    Very funny video - What's your Metaphor?
    Thursday, December 30, 2010 9:21 PM
  • We test and don't allow it, but somehow he managed to get the caret right after a table and tried to force a field insert there. No matter how much you try, users will always find a way...

    Ain't it the truth, though :-)! You gotta wonder, sometimes...

    Glad you got it sorted before the start of the New Year.


    Cindy Meister, VSTO/Word MVP
    Friday, December 31, 2010 8:34 AM
    Moderator