사용할 특성을 정렬 창에서 사용할 수 없는 경우 매크로를
사용하여 정렬하십시오.
시작하기 전에
참고: 이 주제는 Microsoft Word
문서에 생성되는 템플리트에만 적용됩니다.
이 태스크 정보
매크로를 사용하여 정렬하면 다음과 같은 이점이 있습니다.
- 템플리트의 모든 테이블에서 매크로를 실행할 수 있습니다.
- 테이블에서 <RPE_SORT> 주석을 사용하는 경우
해당 테이블이 정렬됩니다.
- <RPE_SORT> 주석을 사용하지 않는 테이블은
정렬되지 않습니다.
- <RPE_SORT> 주석은 최종 출력에서 삭제할 수
있습니다.
프로시저
- 정렬할 열에서 매크로 레이블을 추가하십시오.
- Document Studio 애플리케이션에서 템플리트를 여십시오.
- 정렬할 열의 머리글 셀에서
주석 요소를 추가하십시오.
- 주석 요소를 두 번 클릭한 후 <RPE_SORT>를 입력하십시오.
- 업데이트할 템플리트의 각 테이블에서 반복하십시오.
- 매크로를 작성하십시오.
- Microsoft Word를 여십시오.
- 다음 스크립트를 파일에 복사하여 붙여넣으십시오.
' Macro: sort tables
' This macro is provided as is with no implicit or explicit support from IBM.
Sub sortTables()
Dim tbl As Table
' sort each table
For Each tbl In ActiveDocument.Tables
' determine if the table has header
Dim hasheader As Boolean
hasheader = False
If tbl.Rows.First.HeadingFormat = True Then
hasheader = True
End If
' get the column to do the sorting on. The column is identified by a comment with the "<RPE_SORT>" content in its first cell
Dim hcell As Cell
Dim index As Integer
pos = 0
For Each hcell In tbl.Rows.First.Cells
hcell.Select
If Selection.Comments.Count > 0 Then
If Selection.Comments.Item(1).Range.Text = "<RPE_SORT>" Then
pos = hcell.ColumnIndex
' Delete the comment - remove comment from the line below
' Selection.Comments.Item(1).Delete
Exit For
End If
End If
Next
' sorts the table using the found column
If pos > 0 Then
Dim fldnum As String
fldnum = "Column " + CStr(pos)
Debug.Print "Sorting on: "; fldnum
tbl.Select
Selection.Sort ExcludeHeader:=hasheader, FieldNumber:=fldnum, SortFieldType:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending
End If
Next
End Sub
- 확장자가 .dot인 파일을 저장하십시오.
- 문서 스펙에 매크로를 추가하고 출력을 생성하십시오.
- 문서 스펙을 열거나(문서 스펙이 이미 있는 경우) Launcher 애플리케이션에서
문서 스펙을 작성하십시오.
- 출력을 펼치고 대상: Word를
마우스 오른쪽 단추로 클릭한 후 출력 구성을 선택하십시오.
- Stylesheet에 대해 찾아보기를
클릭하여 작성된 .dot 매크로를 찾으십시오.
- Macro에 대해 매크로 이름을 입력하십시오.
- 출력을 생성하십시오.
다음에 수행할 작업
매크로를 저장하고 문서 스펙에서 재사용하여 데이터를 정렬하십시오.