WD2000: VBA: lm th? no ? ?m cc l?n xu?t hi?n c?a m?t t? ho?c c?m t?

D?ch tiu ? D?ch tiu ?
ID c?a bi: 240157 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TM T?T

Microsoft Word khng cung c?p m?t tnh nng ?c xy d?ng trong ? ?m s? l?n m?t t? ho?c c?m t? ?c s? d?ng trong m?t ti li?u. Tuy nhin, b?ng cch s? d?ng ngn ng? l?p tr?nh trong Word, b?n c th? t?o m?t thi quen m th?c hi?n ch?c nng ny.

THNG TIN THM

Microsoft cung c?p l?p tr?nh v d? ? minh ho? ch?, khng c b?o hnh ho?c th? hi?n hay ng? ?. i?u ny bao g?m, nhng khng gi?i h?n, b?o ?m ng? ? kh? nng bn hng ho?c cho m?t m?c ch c? th?. Bi vi?t ny gi? ?nh r?ng b?n ? quen thu?c v?i ngn ng? l?p tr?nh m ang ?c ch?ng minh v v?i nh?ng cng c? ?c s? d?ng ? t?o ra v g? l?i th? t?c. Microsoft h? tr? cc k? s c th? gip gi?i thch cc ch?c nng c?a m?t th? t?c c? th?, nhng h? s? khng s?a ?i cc v d? ? cung c?p thm ch?c nng ho?c xy d?ng quy tr?nh ? p ?ng cc yu c?u c? th? c?a b?n.

T?o v? m

Sub CountWordPhrase()

Dim x, Response, ExitResponse
Dim y As Integer

' If an error occurs, continue the macro.
On Error Resume Next

AskAgain:

' Ask for the text to count.
x = InputBox("Type the word you want to count and then click OK." _
& Chr$(13) & Chr$(13) & _
"NOTE: This macro will find a whole word only. If the text you typed " _
& "is part of a larger string, it will also be found.")

' If text typed is blank or spaces, then ask to quit.
If x = "" Or x = " " Then
    ExitResponse = MsgBox("You either clicked Cancel or you did " & _
    "not type a word. Do you want to quit?", vbYesNo)
    
    If ExitResponse = 6 Then
        End
    Else
        ' If answer No to quit, then ask for text to count again.
        GoTo AskAgain
    End If
Else

    ' Search for and count occurrences of the text typed.
    With ActiveDocument.Content.find
        Do While .Execute(FindText:=x, Forward:=True, Format:=True, _
           MatchWholeWord:=True) = True
            
           ' Display message in Word's Status Bar.
           StatusBar = "Word is counting the occurrences of the text " & _
           Chr$(34) & x & Chr$(34) & "."
           
           y = y + 1
        Loop
    End With

' Display Message Box with results.
Response = MsgBox("The text " & Chr$(34) & x & Chr$(34) & " was found" _
& Str$(y) & " times.", vbOKOnly)

End If
End Sub
				

Gn m?t phm t?t cho v? m

B?n c th? gn m?t phm t?t cho m?t v? m b?ng cch s? d?ng cc b?c sau:
  1. Trn cc Cng cu tr?nh n, nh?p vo Ty ch?nh.
  2. Nh?p vo Ban phim.
  3. Trong cc Lu cc thay ?i trong h?p, b?m vo cc ti li?u ?c ?i tn ho?c m?u m b?n mu?n lu cc phm t?t nh?ng thay ?i quan tr?ng.
  4. Trong cc Danh muc h?p, b?m vo Macro.
  5. Trong h?p bn ph?i, nh?p vo tn v? m.

    LU ?: Cc phm t?t b?t k? hi?n ang ?c ch? ?nh cho v? m s? xu?t hi?n trong cc Hi?n t?i phm h?p.
  6. Trong cc Bam phm t?t m?i h?p, g? t? h?p phm l?i t?t b?n mu?n ch? ?nh.
  7. Nh?p vo Ch? ?nh.

Ni v? m trn m?t tr?nh n ho?c thanh cng c?

B?n c th? gn v? m cho m?t nt tr?nh n ho?c thanh cng c? b?ng cch s? d?ng cc b?c sau:
  1. Trn cc Cng cu tr?nh n, nh?p vo Ty ch?nh.
  2. B?m vo cc L?nh tab.
  3. D?i Danh muc, b?m Macro.
  4. Trong cc L?nh danh sch, b?m chu?t ph?i vo v? m v ko v? m vo tr?nh n ho?c thanh cng c? c?a b?n mu?n.
  5. Nh?p vo ong ? ng nh?ng Ty ch?nh h?p tho?i.

THAM KH?O

? bi?t thm chi ti?t v? cch s? d?ng m?u m? trong bi vi?t ny, b?m s? bi vi?t d?i y ? xem bi vi?t trong c s? ki?n th?c Microsoft:
212536OFF2000: Lm th? no ? ch?y m?u m? t? bi vi?t c s? ki?n th?c

Thu?c tnh

ID c?a bi: 240157 - L?n xem xt sau cng: 21 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Word 2000 Standard Edition
T? kha:
kbhowto kbmacroexample kbprogramming kbmt KB240157 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:240157

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com