【发布时间】:2010-06-22 16:39:02
【问题描述】:
我正在使用 Microsoft.Office.Interop.Excel COM 接口打开一个 Excel 工作表。我正在尝试调整嵌入工作表的滚动条的“最大值”值。我可以找到带有以下内容的滚动条:
app = new Excel.Application();
wb = app.Workbooks.Open(
Path.GetDirectoryName(Application.ExecutablePath)+@"\template.xls",
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
for (int sheetNum = 1; sheetNum < wb.Sheets.Count + 1; sheetNum++)
{
ws = (Excel.Worksheet)wb.Sheets[sheetNum];
if (ws.Name == "Graphic")
{
foreach (Excel.Shape ctrl in ws.Shapes)
{
if (ctrl.Name == "graphicScroll")
{
// how do a cast this??
break;
}
}
}
break;
}
不过,一旦我获得了形状对象,我就无法确定正确的演员阵容,以便我可以调整它的属性。
有什么想法吗?
谢谢。
【问题讨论】: