2010-06-22 5 views
0

Microsoft.Office.Interop.Excel COM 인터페이스를 사용하여 Excel 워크 시트를 여는 중입니다. 워크 시트에 포함 된 스크롤 막대의 "최대"값을 조정하려고합니다. 그래도 난 모양 객체를 일단 나는 그것이 속성의 조정 할 수 있도록Excel Interop 워크 시트의 ScrollBar 조작

app = new Excel.Application(); 
wb = app.Workbooks.Open(
    Path.GetDirectoryName(Application.ExecutablePath)[email protected]"\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; 
} 

, 나는 적절한 캐스트를 알아낼 수 없습니다 : 나는 다음과 스크롤 막대를 찾을 수 있습니다.

아이디어가 있으십니까?

감사합니다.

답변

0

알아 냈어. OLEObjects를 반복하고 Microsoft.Vbe.Interop.Forms로 캐스팅해야합니다.

Excel.OLEObjects objects = (Excel.OLEObjects) ws.OLEObjects(Type.Missing); 
foreach (Excel.OLEObject ctrl in objects) 
{ 
    if (ctrl.Name == "graphicScroll") 
    {       
    ((Microsoft.Vbe.Interop.Forms.ScrollBar) ctrl.Object).Max = readsAtDeltaMinKeys[readsAtDeltaMin.Count-1]; 
    } 
}