Oliver Lớp 7
Tổng số bài gửi : 185 Join date : 02/12/2010 Age : 34 Đến từ : Bến Tre
| Tiêu đề: Code phần VBA của thầy Tuấn 13/4/2011, 9:25 pm | |
| Các bạn copy sau đó paste vào chương trình viết macro nha. - Code:
-
Sub test() Dim rng As Range Dim keyword() As String Set rng = Selection.Range ReDim keyword(1, 99) With Selection.Find .ClearFormatting .Highlight = True .Text = "" .Forward = True idx = 0 Do While .Execute If Selection.Range.InRange(rng) Then keyword(0, idx) = "" keyword(1, idx) = Selection.Text Selection.Range.HighlightColorIndex = wdNoHighlight Selection.Text = "______" Selection.Collapse direction:=wdCollapseEnd idx = idx 1 Else Exit Do End If Loop idx = idx - 1 If idx = -1 Then MsgBox "Khong tim thay tu khoa!" Exit Sub End If ReDim Preserve keyword(1, idx) rng.Select Selection.Collapse direction:=wdCollapseEnd Selection.TypeParagraph 'bat dau xuat ra may cau A. B. C. idx2 = 0 For idx = 0 To UBound(keyword, 2) Selection.TypeText keyword(1, idx) & vbCrLf idx2 = idx2 1 Next Selection.MoveUp Unit:=wdParagraph, Count:=idx2, Extend:=wdExtend End With With ListGalleries(wdNumberGallery).ListTemplates(4).ListLevels(1) .NumberFormat = "%1." .NumberStyle = wdListNumberStyleUppercaseLetter .StartAt = 1 End With ListGalleries(wdNumberGallery).ListTemplates(4).Name = "" Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _ wdNumberGallery).ListTemplates(4), ContinuePreviousList:=False, ApplyTo:= _ wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior End Sub
Lưu ý: hình như phần code ở trên nó bị lỗi vài chỗ dấu, các bạn download ở đây cho đầy đủ: - Code:
-
http://www.mediafire.com/?0bdo5p6cb8boxwo Chú ý: xem thêm bài hướng dẫn cách download link Mediafire ở đây: Click here
Được sửa bởi Oliver ngày 12/5/2011, 10:46 pm; sửa lần 1. | |
|
coda_edo Lớp 11
Tổng số bài gửi : 410 Join date : 12/12/2010 Age : 33 Đến từ : Đồng Nai
| Tiêu đề: Re: Code phần VBA của thầy Tuấn 4/5/2011, 3:09 pm | |
| | |
|