2013-03-15 3 views
0
Sub Macro1() 
' 
' Macro1 Macro 
' 

' 
    Dim wn, contacts, report As Excel.Window 
    Dim windows(1 To 100) As Excel.Window 
    Dim i As Integer 

    i = 1 
    For Each wn In Application.windows 
     windows(i) = wn 
     i = i + 1 
    Next wn 

    If IsEmailValid(windows(1).Cells(1, 1)) = True Then 
     report = windows(1) 
     contacts = windows(2) 
    Else 
     contacts = windows(1) 
     report = windows(2) 
    End If 


End Sub 

여기서 무엇이 보이지 않습니까? 나는 VBA에 대해 내가 아는 바에 따라 최선을 다하고 있습니다. 의견에 미리 감사드립니다. 당신은 havn't는윈도우 핸들을 변수로 전달

+0

너는하려고하는거야? 작동하지 않는 것은 무엇입니까? FWIW, 당신은 변종으로'wn'과'contacts'를 선언하고 있습니다. –

답변

1
  • 은 (wncontactsvariant의 수와) 올바르게 변수를 선언했다.
    사용 Dim wn As Excel.Window, contacts As Excel.Window, report As Excel.Window
  • 당신은 object
    Set windows(i) = wn
  • window 객체가 Cells 속성이
    당신이 실제로 달성하고자하는 것을 명확하지 않다가없는 할당 Set를 사용해야하지만, 추측 같이 아마 (A workbook에) Worksheets 수집을 원하거나 무엇 가능성이 Application.Workbooks 오히려 Application.Windows보다는