B
boomshanka
I have a visio document from which I wish to modify all shapes and export
pages to HTML. Here is a rough view of the code:
ApplicationClass visioApplication = new ApplicationClass();
short flags = (short)VisOpenSaveArgs.visOpenHidden +
(short)VisOpenSaveArgs.visOpenRW;
Document activeDocument = null;
try
{
Document visioDocument =
visioApplication.Documents.OpenEx(visioFilePath, flags);
activeDocument = visioApplication.ActiveDocument;
int numberOfPages = activeDocument.Pages.Count;
if (numberOfPages > 0)
{
for (int i = 1; i <= numberOfPages; i++)
{
Page page = activeDocument.Pages;
int numberOfShapes = page.Shapes.Count;
for (int j = 1; j <= numberOfShapes; j++)
{
foreach (Hyperlink hyperLink in shape.Hyperlinks)
{
hyperLink.Delete();
}
shape.AddHyperlink();
shape.Hyperlink.Address = myHyperLinkAddress;
string savedFillStyle = shape.FillStyle;
shape.FillStyle = highlightedFillColor;
page.Export(destinationfilePath);
shape.FillStyle = savedFillStyle;
}
page.Export(filePath);
}
}
else
{
Console.WriteLine(string.Format("The document '{0}' did not contain
any pages", activeDocument.Name));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
short savedAlertResponse = visioApplication.AlertResponse;
visioApplication.AlertResponse = 7;
activeDocument.Close();
visioApplication.AlertResponse = savedAlertResponse;
visioApplication.Quit();
}
Note that a few parameters are not declared but they are irrelevant in this
case. If I omit the HyperLink and FillStyle modification, my console
application runs fine, but if I include the modification I receive the
following error when I call Quit():
COMException: {"The remote procedure call failed. (Exception from HRESULT:
0x800706BE)"}
ErrorCode: -2147023170
TargetSite: {Void Quit()}
I'm using "Visio 2007 12.0.6504.5000 SP2 MSO (12.0.6425.1000)" and I have
not been able to track down the cause of the error. Does anyone have a clue
as to what the cause might be?
pages to HTML. Here is a rough view of the code:
ApplicationClass visioApplication = new ApplicationClass();
short flags = (short)VisOpenSaveArgs.visOpenHidden +
(short)VisOpenSaveArgs.visOpenRW;
Document activeDocument = null;
try
{
Document visioDocument =
visioApplication.Documents.OpenEx(visioFilePath, flags);
activeDocument = visioApplication.ActiveDocument;
int numberOfPages = activeDocument.Pages.Count;
if (numberOfPages > 0)
{
for (int i = 1; i <= numberOfPages; i++)
{
Page page = activeDocument.Pages;
int numberOfShapes = page.Shapes.Count;
for (int j = 1; j <= numberOfShapes; j++)
{
foreach (Hyperlink hyperLink in shape.Hyperlinks)
{
hyperLink.Delete();
}
shape.AddHyperlink();
shape.Hyperlink.Address = myHyperLinkAddress;
string savedFillStyle = shape.FillStyle;
shape.FillStyle = highlightedFillColor;
page.Export(destinationfilePath);
shape.FillStyle = savedFillStyle;
}
page.Export(filePath);
}
}
else
{
Console.WriteLine(string.Format("The document '{0}' did not contain
any pages", activeDocument.Name));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
short savedAlertResponse = visioApplication.AlertResponse;
visioApplication.AlertResponse = 7;
activeDocument.Close();
visioApplication.AlertResponse = savedAlertResponse;
visioApplication.Quit();
}
Note that a few parameters are not declared but they are irrelevant in this
case. If I omit the HyperLink and FillStyle modification, my console
application runs fine, but if I include the modification I receive the
following error when I call Quit():
COMException: {"The remote procedure call failed. (Exception from HRESULT:
0x800706BE)"}
ErrorCode: -2147023170
TargetSite: {Void Quit()}
I'm using "Visio 2007 12.0.6504.5000 SP2 MSO (12.0.6425.1000)" and I have
not been able to track down the cause of the error. Does anyone have a clue
as to what the cause might be?