Exibir todas as fontes instaladas (Word) usando VBA no Microsoft Excel

Anonim

As macros abaixo exibirão uma lista de todas as fontes instaladas. Observação! Se você tiver muitas fontes instaladas,
a macro pode parar de responder devido à falta de memória disponível.

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 ("Insira o tamanho da fonte de amostra entre 8 And 30 ", _" Selecione 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 Nothing Then Set FontCmdBar = Application.CommandBars.Add ("TempFontNamesCtrl", _ msoBarFloating, False, True) Defina FontNamesCtrl = FontCmdBar.Controls.Add (ID: = 1728) End If Application.ScreenUpdating = False fontCount = FontNamesCtrl.List Documents. Adicionar stdFont = ActiveDocument.Paragraphs (1) .Range.Font.Name 'add header With ActiveDocument.Paragraphs (1) .Range .Text = "Fontes instaladas:" End With LS 2' lista os nomes das fontes e exemplos de fontes a cada duas linhas Para i = 0 Para FontNamesCtrl.ListCount - 1 fontName = FontName sCtrl.List (i + 1) If i Mod 5 = 0 Then Application.StatusBar = "Listando fonte" & _ Format (i / (fontCount - 1), "0%") & "" & _ fontName & "…" Com ActiveDocument.Paragraphs (ActiveDocument.Paragraphs.Count) .Range .Text = fontName .Font.Name = stdFont End With LS 1 tFormula = "abcdefghijklmnopqrstuvwxyz" If Application.International (wdProductLanguulaID) = 47 Then tForm " 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 If Not FontCmdBar Is Nothing Then FontCmdBar.Delete Set FontCmdBar = Nothing Set FontNamesCtrl = Nada ActiveDocument.Saved = True Application.ScreenUpdating = True Application.ScreenRefresh End Sub Private Sub LS (lCount como inteiro) ' adiciona lCount novo (s) parágrafo (s) no final do documento Dim i As Integer With ActiveDo cument.Content For i = 1 To lCount .InsertParagraphAfter Next i End With End Sub