2014-06-20 2 views
0

안녕하세요. 슬라이서를 거쳐 필터링되어 있는지 확인하는 데 어려움이 있습니다.슬라이서 값을 워크 시트에 저장

내 목표는 선택한 피겨를 워크 시트로 가져 와서 기본 피벗 데이터에 (높음에서 낮음) 필터를 적용하여 선택한 항목을 기반으로 "예산 초과 5 위"를 선택할 수있게하는 것입니다. 데이터 슬라이서에서.

나는 다음과 같은 코드를 가지고 있지만 오류가 얻을 : Run Time Error 438’ Object doesn’t support this method

누군가가 내가 이것을 달성하는 방법을 조언 해 줄 수 있습니다.

Public Sub top_over_under_booked() 
    Dim oSi As SlicerItem 
    Dim oSlicercache As SlicerCache 
    Dim oSl As SlicerCacheLevel 
    Dim oPt As PivotTable 
    Dim oSh As Worksheet 
    Set target_ws = ThisWorkbook.Worksheets("Get Slicer Selections") 
    For Each oSlicercache In ThisWorkbook.SlicerCaches 

     For Each oPt In oSlicercache.PivotTables 

      oPt.Parent.Activate  'Slice Name 
      worksheet_name = UCase(oPt.Parent.Name) 
      If worksheet_name = UCase("Chart Analysis 5 Years") Then 
       column_no = 0 
       slicer_name = UCase(oSlicercache.Name) 
       Select Case UCase(oSlicercache.Name) 
        Case Is = "SLICER_FY1" 
         column_no = 1 
        Case Is = "SLicer_REPORT_PT_DEPT1" 
         column_no = 2 
        'There are actually loads more slicer which needs to ne ignored. 
       End Select 
       If column_no <> 0 Then 
        For Each oSl In ActiveWorkbook.SlicerCaches(oSlicercache.Name) ' <----- Error 
         For Each oSi In oSl.SlicerItems 
          'oSi.Selected = True 
          check_slicer_string = oSi.Value 
          'target_ws.Cells(ource_ws.Cells(65000, column_no).End(xlUp).Row + 1, column_no) = oSlicercache.Value 
         Next 
        Next 
       End If 
       oPT.Parent.Name 
      End If 
     Next 
    Next 
End Sub 

답변

0

가 두 개의 서로 다른 Excel의

Microsoft.Office.Tools.Excel를 사용하여; Excel을 사용하는 = Microsoft.Office.Interop.Excel; ThisWorkBook.cs 내

public string SelectedReportCategories() 
    { 
     var selection = ""; 

     var myTarget = this; 

     try 
     { 
      var caches = myTarget.SlicerCaches["Slicer_REPORT"]; 

      foreach (Excel.SlicerItem slicerItem in caches.SlicerItems) 
      { 
       if (slicerItem.Selected) 
        selection = selection + " " + slicerItem.Name; 
      } 
     } 
     catch (Exception e) 
     { 
      ShowError("Configuration", (e.InnerException != null) ? e.InnerException.Message : e.Message); 
     } 

     return selection; 
    } 
관련 문제