Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print all fonts in a word document using a macro... 2

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]
Hello all, I'm trying to print a sample text "TEST" on a word document of all the fonts installed on my machine.

Would someone be so kind to direct me to either a script or a place to read on how to accomplish this.

Thanks in advance.


Got ASP Error(s)? =
 
Try this:

Sub fonts()
Dim f
Documents.Add
For Each f In Application.FontNames
Selection.Font.Name = f
Selection.TypeText "Test: " & f & vbCr
Next f
End Sub
Rob
[flowerface]
 
[tt]
Thanks Rob, I may need your assistance again soon if I want to display the "TEST" in different sizes and colors...



Got ASP Error(s)? =
 
Hi
Word ain't my thing really but you could try this

Code:
Sub ListFonts()
Dim ft
Dim stFont
Selection.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(7.5), _
     Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
For Each ft In Application.FontNames
    With Selection
        .font.Name = ft
        .TypeText Text:=ft
        .font.Name = "Arial"
        .TypeText Text:=vbTab & ft
        .TypeParagraph
    End With
Next
End Sub

Should list all fonts in an active document. I'd suggest creating a new doc to be on the safe side as I don't really know what kind of problems you may run into.

;-) If a man says something and there are no women there to hear him, is he still wrong?
 
MMMMMmmmmmmmm
The answer wasn't there when I posted! It would help if I had a reliable ISP!! Anyway, half of mine was just recorded to see if I could do it!!!!

;-) If a man says something and there are no women there to hear him, is he still wrong?
 
[tt]
Actually your suggestion also helped Loomah. Thanks

--------------------------------------------
Now what I'm trying to accomplish is displaying the fonts in say 3 or 4 different sizes much like when you open a font in the windows control panel

example

Times New Roman (True Type)
abc... (lower case)
ABC... (UPPER CASE)
123...

14 point Font: This is only a test...

18 point Font: This is only a test...

30 point Font: This is only a test...

40 point Font: This is only a test...


Not sure if this is possible. But any assistance is greatly appreciated.


Got ASP Error(s)? =
 
Just about anything is possible. Using the VBA commands you've already encountered in Loomah's and my examples, you can put text into the document. You get the different sizes with

selection.font.size=18 (etc.)

Play around with it a bit - you'll find it's quite easy. And we're always here to help when you get stuck :)
Rob
[flowerface]
 
[tt]

I'm now trying to print a short sentence on my document in all the installed fonts in bold but I'm stuck

I have this: "Static TEXT" typed on my word document and I'm trying to print in bold as many times as there are fonts on my machine but can't do it. I'm NOT trying to print it all to one page but to one page per font type\style.

Sub fonts()
Dim f
Documents.Add
For Each f In Application.FontNames
Selection.Style = Bold
Selection.Font.Name = f
Selection.TypeText "This font is called : " & f & vbCr
Selection.Document
Next f
End Sub

basically, I have 20 fonts installed and would like 20 different sheets created

Thanks


Got ASP Error(s)? =
 
To start a new page, use

selection.insertbreak wdPageBreak

to turn bold on, use

selection.font.bold=true

Rob
[flowerface]
 
[tt]

Q. How do I determine how many words my document have?

As I'm reading more about how object components work I'm getting more confused as to how they are used.

I'm begining to think that a Object.Range(start,end) range will have to be used with what I'm trying to do but I don't know enough vba syntax to know what I'm doing.


Got ASP Error(s)? =
 
tony
here's what i came up with but i don't know word vba - the key to vba (in my opinion) is knowing the application. this line makes perfect sense to me but returns the wrong answer!

Code:
ActiveDocument.Words.Count

i wrote the numbers one to sixteen out then performed this test and got the answer 17! maybe it should be

Code:
ActiveDocument.Words.Count - 1

but i have no idea why

over to you rob! i'm interested by this - seems a basic little exercise and now i'm looking to learn a little about word vba here!

;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Excel is my forte. I can dabble in Word, but I'm a lot fuzzier on its object model. I dislike having to use the selection object all the time (I never use it in Excel).
At any rate, I'll yield the floor to the Word VBA experts in our midst...
Rob
[flowerface]
 
[tt]Having dabbled with vba a long time ago for a very short period of time and deciding to work with .ASP instead, I'm very ignorant when it comes to it and need all the help I can get. Thanks guys.


Got ASP Error(s)? =
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top