J
joniba
Hi all, I'm not sure if this is the right place to post this, but:
I am trying to work with the PIA for microsoft word from VS2008, framework
3.5. I am working in a class library with a reference to the Office 12 PIA.
I have Office 2003 (only) installed.
I am getting a lot of exceptions I do not understand and I cannot find
documentation to explain, so any help would be greatly appreciated (as well
as documentation, if anyone knows of any).
First, trying to edit a range is always throwing an exception, whether it in
this format (I'm just pasting some of the relevant lines from the code):
oTable = doc.Tables[iTable]
oRange = oTable.Rows[iRow].Cells[3].Range;
oRange.Text = ""; // exception thrown here
Or if the last line is written like this instead:
object count = oRange.Characters.Count;
object charUnit = WdUnits.wdCharacter;
oRange.Delete(ref charUnit , ref count); // throws exception
In the second case the exception message is:
"Cannot edit Range."
In the first case I get HRESULT: 0x80010105 exception where the code stack
shows that the exception occurred in "set_Range" method in the RPC server.
Here are two more examples that return this same HRESULT: 0x80010105:
The last line in this code that is working with a Document word object
(called "doc") throws an exception:
Range oRange = doc.Content;
oRange.Find.ClearFormatting();
oRange.Find.MatchWildcards = true;
oRange.Find.ParagraphFormat.Alignment =
WdParagraphAlignment.wdAlignParagraphCenter; // throws exception
The following line also throws an exception:
oTable.Cell(iSide1Row, 2).Range.Text = strOriginal;
Where I've checked that both "strOriginal" and "oTable.Cell(iSide1Row,
2).Range.Text" evaluate to proper strings.
Tell me if you need to see more code.
I am trying to work with the PIA for microsoft word from VS2008, framework
3.5. I am working in a class library with a reference to the Office 12 PIA.
I have Office 2003 (only) installed.
I am getting a lot of exceptions I do not understand and I cannot find
documentation to explain, so any help would be greatly appreciated (as well
as documentation, if anyone knows of any).
First, trying to edit a range is always throwing an exception, whether it in
this format (I'm just pasting some of the relevant lines from the code):
oTable = doc.Tables[iTable]
oRange = oTable.Rows[iRow].Cells[3].Range;
oRange.Text = ""; // exception thrown here
Or if the last line is written like this instead:
object count = oRange.Characters.Count;
object charUnit = WdUnits.wdCharacter;
oRange.Delete(ref charUnit , ref count); // throws exception
In the second case the exception message is:
"Cannot edit Range."
In the first case I get HRESULT: 0x80010105 exception where the code stack
shows that the exception occurred in "set_Range" method in the RPC server.
Here are two more examples that return this same HRESULT: 0x80010105:
The last line in this code that is working with a Document word object
(called "doc") throws an exception:
Range oRange = doc.Content;
oRange.Find.ClearFormatting();
oRange.Find.MatchWildcards = true;
oRange.Find.ParagraphFormat.Alignment =
WdParagraphAlignment.wdAlignParagraphCenter; // throws exception
The following line also throws an exception:
oTable.Cell(iSide1Row, 2).Range.Text = strOriginal;
Where I've checked that both "strOriginal" and "oTable.Cell(iSide1Row,
2).Range.Text" evaluate to proper strings.
Tell me if you need to see more code.