Afișați toate fonturile instalate (Word) folosind VBA în Microsoft Excel

Cuprins

Macrocomenzile de mai jos vor afișa o listă cu toate fonturile instalate. Notă! Dacă aveți multe fonturi instalate,
macro-ul poate să nu mai răspundă din cauza lipsei de memorie disponibilă.

Sub ShowInstalledFonts () Dim FontNamesCtrl As CommandBarControl, FontCmdBar As CommandBar, tFormula As String Dim fontName As String, i As Long, fontCount As Long, fontSize As Integer Dim stdFont As String fontSize = 0 fontSize = InputBox ("Enter Sample Font Size Between 8 Și 30 ", _" Select Sample Font Size ", 12) If fontSize = 0 Then Exit Sub If fontSize 30 Then fontSize = 30 Set FontNamesCtrl = Application.CommandBars (" Formatting "). FindControl (ID: = 1728) If FontNamesCtrl Is Nimic atunci Set FontCmdBar = Application.CommandBars.Add ("TempFontNamesCtrl", _ msoBarFloating, False, True) Set FontNamesCtrl = FontCmdBar.Controls.Add (ID: = 1728) End If Application.ScreenUpdating = False fontCount = FontNamesCtrl. Adăugați stdFont = ActiveDocument.Paragraphs (1) .Range.Font.Name 'add heading With ActiveDocument.Paragraphs (1) .Range .Text = "Fonturi instalate:" Încheiați cu LS 2' lista de nume de fonturi și exemplu de font pe fiecare altă linie For i = 0 To FontNamesCtrl.ListCount - 1 fontName = FontName sCtrl.List (i + 1) Dacă i Mod 5 = 0 atunci Application.StatusBar = "Font listare" & _ Format (i / (fontCount - 1), "0%") & "" & _ fontName & "…" Cu ActiveDocument.Paragraphs (ActiveDocument.Paragraphs.Count) .Range .Text = fontName .Font.Name = stdFont End With LS 1 tFormula = "abcdefghijklmnopqrstuvwxyz" If Application.International (wdProductLanguageID) = 47 Then tFormula = tFormula If tFormula = tFormula & UCase (tFormula) tFormula = tFormula & "1234567890" With ActiveDocument.Paragraphs (ActiveDocument.Paragraphs.Count) .Range .Text = tFormula .Font.Name = fontName End With LS 2 Next i ActiveDocument.Content.Font .Size = fontSize Application.StatusBar = False Dacă nu FontCmdBar nu este nimic, atunci FontCmdBar.Delete Set FontCmdBar = Nimic setat FontNamesCtrl = Nimic ActiveDocument.Saved = Adevărat Application.ScreenUpdating = Adevărat Application.ScreenRefresh End Sub Private Sub LS (lCount Ca întreg) ' adaugă lCount noi paragrafe la sfârșitul documentului Dim i As Integer With ActiveDo cument.Content For i = 1 To lCount .InsertParagraphAfter Next i End With End Sub

Vei ajuta la dezvoltarea site-ului, partajarea pagina cu prietenii

wave wave wave wave wave