2013-07-05 3 views
0

단어 문서에서 다음 트랙 변경을 발견 한 다음 페이지 번호가있는 메시지 상자를 표시하는 VBS가 있습니다.VBS 루프에서 배열로 값을 추가합니다.

이 루프는 문제가 없지만이 'CurPage'변수를 단일 배열에 추가하면됩니다. 따라서 msgbox 36보다는 msgbox 38 - msgbox 36, 38 등입니다.

또한 루프를 종료하려면 파일 끝을 처리해야합니다.

Dim i As Integer 
i = 0 

'get us home 
    Selection.HomeKey Unit:=wdStory 

Do 
'find next change 
    WordBasic.NextChangeOrComment 

'get current page 
    CurPage = Selection.Information(wdActiveEndAdjustedPageNumber) 
    MsgBox (CurPage) 

'<Add CurPage value to array> 

'<find out if we have reached the end of file, if so end loop> 


    i = i + 1 
Loop Until i = 188 
End Sub 

답변

0

첫 번째 질문에 답변 해 드리겠습니다; 완전히 다른 주제이기 때문에 두 번째 (루프 종료) 게시물을 별도로 작성해야합니다.

배열이 필요하지 않습니다. MsgBox으로 표시 할 수있는 문자열이 필요합니다.

Dim i As Integer 
    Dim Pages as String 

    i = 0 
    Pages = "";  

    'get us home 
    Selection.HomeKey Unit:=wdStory 

    Do 
    'find next change 
    WordBasic.NextChangeOrComment 

    'get current page 
    CurPage = Selection.Information(wdActiveEndAdjustedPageNumber) 
    Pages = Pages & ", " & CurPage 

    '<Add CurPage value to array> 

    '<find out if we have reached the end of file, if so end loop> 

    i = i + 1 
    Loop Until i = 188 
    MsgBox Pages 

End Sub 
관련 문제