W
Webbert
I have a Visio add-in that gets an error when opening a diagram.
The steps I take are
1) Open diagram
2) Cut/copy from a Word/RTF file and paste it as the name of shape
3) Call Document.SaveAs()
4) Close diagram
5) Open diagram
After I get the error dialog and continue on, then do a Document.SaveAs the
problem is gone then next time I open the diagram. This would indicate that
something is cleaning up the issue after opening.
I would like to resolve the issue at the time of the save but am not sure
what else to do to find/fix the issue.
Any thoughts are appreciated.
Below is the Error Message and Attempts to fix the issue.
=============
Open Error Dialog:
-------------
The file was opened but some problems were encountered.
Details of the problems were added to the log file.
=============
Log File:
-------------
[Warning] DataType:
Context:
<VisioDocument><Pages><Page><Shapes><Shape><Shapes><Shape><Text><cp><cp>
Description: This file contains an unexpected Visio XML element. Visio has
ignored the element.
[Warning] DataType:
Context: <VisioDocument><Pages><Page ID='0'
Name='Front'><PageSheet><Shapes><Shape ID='23' Name='650
(F)'><Shapes><Shape ID='25'>
Description: The shape contains a text property row element that is not
referenced from the shape's text. Visio has ignored the element.
Element: <Char IX='1' ... />
=============
I tried to clean before SaveAs(), which had no effect
Microsoft.Office.Interop.Visio.Document diagram = ...
... DO STUFF ...
diagram.Clean(
VisDocCleanTargets.visDocCleanTargAll,
VisDocCleanActions.visDocCleanActDefault,
VisDocCleanActions.visDocCleanAlertDefault,
VisDocCleanActions.visDocCleanFixDefault,
false,
null,
null);
diagram.SaveAs(filename);
I also tried to change the values of the Cells, which had an effect that
could seen on the diagram, but didn't fix the issue.
// Get Cells
Cell cellColor = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterColor);
Cell cellFont = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterFont);
Cell cellSize = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterSize);
Cell cellProperties = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterStyle);
// Get formatting
color = cellColor.get_ResultStr(VisUnitCodes.visNoCast);
font = (int)cellFont.ResultIU;
size = cellSize.get_Result( VisUnitCodes.visPoints);
style = (int)cellProperties.ResultIU;
bold = ((style & 1) == 1);
italic = ((style & 2) == 2);
underline = ((style & 4) == 4);
// RESET VALUES
cellColor.set_Result(VisUnitCodes.visNoCast, 0); // Black
cellFont.ResultIU = 4; // Arial
cellSize.set_Result((short)VisUnitCodes.visPoints, 24); // 24 Point
cellProperties.ResultIU = 0; // No Bold,
Italic, or Underline
The steps I take are
1) Open diagram
2) Cut/copy from a Word/RTF file and paste it as the name of shape
3) Call Document.SaveAs()
4) Close diagram
5) Open diagram
After I get the error dialog and continue on, then do a Document.SaveAs the
problem is gone then next time I open the diagram. This would indicate that
something is cleaning up the issue after opening.
I would like to resolve the issue at the time of the save but am not sure
what else to do to find/fix the issue.
Any thoughts are appreciated.
Below is the Error Message and Attempts to fix the issue.
=============
Open Error Dialog:
-------------
The file was opened but some problems were encountered.
Details of the problems were added to the log file.
=============
Log File:
-------------
[Warning] DataType:
Context:
<VisioDocument><Pages><Page><Shapes><Shape><Shapes><Shape><Text><cp><cp>
Description: This file contains an unexpected Visio XML element. Visio has
ignored the element.
[Warning] DataType:
Context: <VisioDocument><Pages><Page ID='0'
Name='Front'><PageSheet><Shapes><Shape ID='23' Name='650
(F)'><Shapes><Shape ID='25'>
Description: The shape contains a text property row element that is not
referenced from the shape's text. Visio has ignored the element.
Element: <Char IX='1' ... />
=============
I tried to clean before SaveAs(), which had no effect
Microsoft.Office.Interop.Visio.Document diagram = ...
... DO STUFF ...
diagram.Clean(
VisDocCleanTargets.visDocCleanTargAll,
VisDocCleanActions.visDocCleanActDefault,
VisDocCleanActions.visDocCleanAlertDefault,
VisDocCleanActions.visDocCleanFixDefault,
false,
null,
null);
diagram.SaveAs(filename);
I also tried to change the values of the Cells, which had an effect that
could seen on the diagram, but didn't fix the issue.
// Get Cells
Cell cellColor = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterColor);
Cell cellFont = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterFont);
Cell cellSize = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterSize);
Cell cellProperties = GetCell(vsoShape, iRow, charSection,
VisCellIndices.visCharacterStyle);
// Get formatting
color = cellColor.get_ResultStr(VisUnitCodes.visNoCast);
font = (int)cellFont.ResultIU;
size = cellSize.get_Result( VisUnitCodes.visPoints);
style = (int)cellProperties.ResultIU;
bold = ((style & 1) == 1);
italic = ((style & 2) == 2);
underline = ((style & 4) == 4);
// RESET VALUES
cellColor.set_Result(VisUnitCodes.visNoCast, 0); // Black
cellFont.ResultIU = 4; // Arial
cellSize.set_Result((short)VisUnitCodes.visPoints, 24); // 24 Point
cellProperties.ResultIU = 0; // No Bold,
Italic, or Underline