Fields.Add() -> COMException This command is not available

D

David Thielen

This code has worked forever:

object fieldType = WdFieldType.wdFieldAutoTextList;
object fieldText = "\"<xyDate>\" \\t \"<wr:chart style='default'
graph0-data0-select='${data}/@day' graph0-data1-select='${data}/@num'
graph0-data1-type='number' graph0-rows-select='${series}/elem'
graph0-select='/data/xyDate' graph0-series-select='${series}/@name'
graph0-type='column:clustered'/>\"";
object preserveFormatting = false;
Field fld = app.NativeDocument.Fields.Add(rng, ref fieldType, ref
fieldText, ref preserveFormatting);

But now I get a:
System.Runtime.InteropServices.COMException occurred
HelpLink="C:\\Program Files\\Microsoft
Office\\Office12\\1033\\WDMAIN11.CHM#37373"
Message="This command is not available."
Source="Microsoft Word"
ErrorCode=-2146823683
StackTrace:
at Microsoft.Office.Interop.Word.Fields.Add(Range Range,
Object& Type, Object& Text, Object& PreserveFormatting)
at
AutoTag2010.net.windward.autotag.word.WordTagHandler.WriteTag(WordTagLocation
tag, Image picture, ChartDataSet chartData) in
C:\src\version9\AutoTag\AutoTag2010\net\windward\autotag\word\WordTagHandler.cs:line
1388
InnerException:

Any idea why?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
C

Colbert Zhou [MSFT]

Hello Dave,

Does this error happen always or randomly? Do you reproduce it locally or
receive the report from a customer? I have a quick test with the codes, it
works fine for me. Based on my researches on the web, the error "This
command is not available" usually happens when the end user tries to do
some manipluations while the target document is locked for edit.
http://support.microsoft.com/default.aspx/kb/316032?p=1

So perhaps, an end user locks the document to prevent from editing, and run
your solution. Then the error comes up.


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

It happened here - just once. Have not been able to recreate it. Maybe
it was just a very unusual combination of events.

thanks - dave


Hello Dave,

Does this error happen always or randomly? Do you reproduce it locally or
receive the report from a customer? I have a quick test with the codes, it
works fine for me. Based on my researches on the web, the error "This
command is not available" usually happens when the end user tries to do
some manipluations while the target document is locked for edit.
http://support.microsoft.com/default.aspx/kb/316032?p=1

So perhaps, an end user locks the document to prevent from editing, and run
your solution. Then the error comes up.


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top