nguyenphanna
Thành viên mới

- Tham gia
- 29/8/11
- Bài viết
- 32
- Được thích
- 3
Chào các bạn, mình thường hay phải soạn bài, trong bài thường bổ sung các hình ảnh từ nhiều nguồn tài liệu. Do đó nên phải đánh số thứ tự lại các hình. Thông qua google, mình đã tổng hợp thành một macro tự tăng thứ tự hình, nhưng mà nó không nhận ra đâu là cuối cùng nên nó cứ lặp đi lặp lại. Nhờ mọi người xem giúp mình với ạ. Mình cảm ơn nhiều ạ
Sub Tangsothutuhinh()
Dim xFindStr As String
Dim xReplaceStr As String
Dim m As Integer
m = 0
xFindStr = InputBox("Find what:", "Tim", xFindStr)
xReplaceStr = InputBox("Replace with:", "Thay the", xReplaceStr)
CommandBars("Navigation").Visible = False
Do
m = m + 1
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = xFindStr 'Find What
.Replacement.Text = xReplaceStr & m & ". " 'Replace With
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceOne
Loop Until Selection.Range.Bookmarks.Exists("\EndOfDoc") = True ' cho Ðê'n cuô'i document
MsgBox "Operation end, please view", vbInformation
End Sub
Mình xem thấy toàn không thấy điều kiện Loop ấy ạ. Loop Until Selection.Range.Bookmarks.Exists("\EndOfDoc") = True ' cho Ðê'n cuô'i document
Sub Tangsothutuhinh()
Dim xFindStr As String
Dim xReplaceStr As String
Dim m As Integer
m = 0
xFindStr = InputBox("Find what:", "Tim", xFindStr)
xReplaceStr = InputBox("Replace with:", "Thay the", xReplaceStr)
CommandBars("Navigation").Visible = False
Do
m = m + 1
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = xFindStr 'Find What
.Replacement.Text = xReplaceStr & m & ". " 'Replace With
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceOne
Loop Until Selection.Range.Bookmarks.Exists("\EndOfDoc") = True ' cho Ðê'n cuô'i document
MsgBox "Operation end, please view", vbInformation
End Sub
Mình xem thấy toàn không thấy điều kiện Loop ấy ạ. Loop Until Selection.Range.Bookmarks.Exists("\EndOfDoc") = True ' cho Ðê'n cuô'i document