Prikaz vseh nameščenih pisav (Word) z uporabo VBA v programu Microsoft Excel

Anonim

Spodnji makri bodo prikazali seznam vseh nameščenih pisav. Opomba! Če imate nameščenih veliko pisav,
makro se lahko preneha odzivati ​​zaradi pomanjkanja razpoložljivega pomnilnika.

Sub ShowInstalledFonts () Dim FontNamesCtrl Kot CommandBarControl, FontCmdBar Kot CommandBar, tFormula As String Dim fontName As String, i As Long, fontCount As Long, fontSize As Integer Dim stdFont As String fontSize = 0 fontSize = Vnos Vnos In 30 ", _" Izberite velikost vzorčne pisave ", 12) Če je fontSize = 0 Potem zapustite Sub Če je fontSize 30 Potem fontSize = 30 Nastavite FontNamesCtrl = Application.CommandBars (" Oblikovanje "). FindControl (ID: = 1728) Če je FontNamesCtrl Nič. Nato nastavite FontCmdBar = Application.CommandBars.Add ("TempFontNamesCtrl", _ msoBarFloating, False, True) Nastavite FontNamesCtrl = FontCmdBar.Controls.Add (ID: = 1728) End If Application.ScreenUpdating = FalseConCentRec. Dodaj stdFont = ActiveDocument.Paragraphs (1) .Range.Font.Name 'dodaj naslov With ActiveDocument.Paragraphs (1) .Range .Text = "Nameščene pisave:" Končaj z LS 2 "imena pisav in primerov pisav v vsaki drugi vrstici Za i = 0 Za FontNamesCtrl.ListCount - 1 fontName = Ime pisave sCtrl.List (i + 1) Če je i Mod 5 = 0, potem Application.StatusBar = "Pisava seznama" & _ Oblika (i / (fontCount - 1), "0 %") & "" & _ fontName & "…" Z ActiveDocument.Paragraphs (ActiveDocument.Paragraphs.Count) .Range .Text = fontName .Font.Name = stdFont Končaj z LS 1 tFormula = "abcdefghijklmnopqrstuvwxyz" Če je aplikacija.Međunarodna (wdProductLanguage} Če je tFormula = tFormula & UCase (tFormula) tFormula = tFormula & "1234567890" z ActiveDocument.Paragrafi (ActiveDocument.Paragraphs.Count). Range .Text = tFormula. .Size = fontSize Application.StatusBar = False Če ni FontCmdBar ni nič, potem FontCmdBar.Delete Set FontCmdBar = Nothing Set FontNamesCtrl = Nothing ActiveDocument.Saved = True Application.ScreenUpdating = True Application.ScreenRefresh End Sub Private Sub LS (lC) doda l Preštej nove odstavke na koncu dokumenta Dim i As Integer With ActiveDo cument.Content For i = 1 To lCount .InsertParagraphAfter Next i End With End Sub