Էս մակրոն հարկավոր ա տեղադրել փաստաթղթում ու աշխատեցնել։Կոդ:Sub WordFrequency() Const maxwords = 9000 'Maximum unique words allowed Dim SingleWord As String 'Raw word pulled from doc Dim Words(maxwords) As String 'Array to hold unique words Dim Freq(maxwords) As Integer 'Frequency counter for unique words Dim WordNum As Integer 'Number of unique words Dim ByFreq As Boolean 'Flag for sorting order Dim ttlwds As Long 'Total words in the document Dim Excludes As String 'Words to be excluded Dim Found As Boolean 'Temporary flag Dim j, k, l, Temp As Integer 'Temporary variables Dim ans As String 'How user wants to sort results Dim tword As String ' ' Set up excluded words ' Excludes = "[the][a][of][is][to][for][by][be][and][are]" ' Find out how to sort ByFreq = True ans = InputBox("Sort by WORD or by FREQ?", "Sort order", "WORD") If ans = "" Then End If UCase(ans) = "WORD" Then ByFreq = False End If Selection.HomeKey Unit:=wdStory System.Cursor = wdCursorWait WordNum = 0 ttlwds = ActiveDocument.Words.Count ' Control the repeat For Each aword In ActiveDocument.Words SingleWord = Trim(LCase(aword)) 'Out of range? 'If SingleWord < "a" Or SingleWord > "z" Then ' SingleWord = "" 'End If 'On exclude list? If InStr(Excludes, "[" & SingleWord & "]") Then SingleWord = "" End If If Len(SingleWord) > 0 Then Found = False For j = 1 To WordNum If Words(j) = SingleWord Then Freq(j) = Freq(j) + 1 Found = True Exit For End If Next j If Not Found Then WordNum = WordNum + 1 Words(WordNum) = SingleWord Freq(WordNum) = 1 End If If WordNum > maxwords - 1 Then j = MsgBox("Too many words.", vbOKOnly) Exit For End If End If ttlwds = ttlwds - 1 StatusBar = "Remaining: " & ttlwds & ", Unique: " & WordNum Next aword ' Now sort it into word order For j = 1 To WordNum - 1 k = j For l = j + 1 To WordNum If (Not ByFreq And Words(l) < Words(k)) _ Or (ByFreq And Freq(l) > Freq(k)) Then k = l Next l If k <> j Then tword = Words(j) Words(j) = Words(k) Words(k) = tword Temp = Freq(j) Freq(j) = Freq(k) Freq(k) = Temp End If StatusBar = "Sorting: " & WordNum - j Next j ' Now write out the results tmpName = ActiveDocument.AttachedTemplate.FullName Documents.Add Template:=tmpName, NewTemplate:=False Selection.ParagraphFormat.TabStops.ClearAll With Selection For j = 1 To WordNum .TypeText Text:=Trim(Str(Freq(j))) _ & vbTab & Words(j) & vbCrLf Next j End With System.Cursor = wdCursorNormal j = MsgBox("There were " & Trim(Str(WordNum)) & _ " different words ", vbOKOnly, "Finished") End Sub
artak.amDe gustibus et coloribus non est disputandum.
Varzor (22.05.2012)
Եթե հայերեն տեքստը յունիկոդ չի` նորմալ չի անի, մանավանդ եթե ՕՀ համակարգային լեզուն ռուսերեն լինի: Այ էս հրամանը ախմախ Word-ը սխալ ա անում` ActiveDocument.Words չի կարողանու հայերեն բառերն առանձնացնել:
Համ էլ էս մակրոն անգլերեն տեքստերի համար է ու սահմանափակ բառերով տեքստի համար, կոնկրետ` 9000: Բայց կարելի է ձևափոխել ու ոչ յունիկոդ հայերենի համար էլ ստանալ![]()
Լոխ մունք ենք, մնացածը` լոխ են...
Այցելած կայքերի պատմությունը որոշ տվյալներ ցույց չի տալիս, ինքս դրանք չեմ հեռացրել: Ի՞նչը կարող է լինել դրա պատճառը: Օգտվում եմ Google Chrome browser-ից Խնդրում եմ օգնեք անչափ կարեւոր է
Some people cause happiness wherever they go, others - whenever they go!
keyboard (25.05.2012)
Վերջին խմբագրող՝ Varzor: 25.05.2012, 18:59:
Լոխ մունք ենք, մնացածը` լոխ են...
Սա փորձել եմ ու փրկելա:
Բանն այն է, որ երբ միջատը քայլում է գնդի վրայով չի նկատում, որ հետագիծը կորանում է... ինձ բախտ վիճակվեց նկատել այդ:
Varzor (29.05.2012)
Windows 7 32 bit օպերացիոն համակարգում դեսկթոպս չգիտես ինչի ուղղակի կախում ա, ու ոչինչ չի լինում անել մինչև, որ ռեստառտ չանեմ: Ինչի՞ հետ ա կապված խնդիրը, նոր ֆոռմատ եմ արել ավաստնել քցել…
Կոմպիս վրա Windows 7 Professional x64 ռուսական տարբերակն ա նստացրած: Win7-ի Professional տարբերակներում Language settings-ում չի լինում լեզուների համապատասխան ցուցակը: Գուգլն էլ հարմար բան չտվեց: Ո՞նց լեզուն փոխեմ անգլերենի:
Այս պահին թեմայում են 1 հոգի. (0 անդամ և 1 հյուր)
Էջանիշներ