How to add 2 tabulations after string?

A

avkokin

Hello.
There is code (below). I need to add after string (.TypeText
Text:=aFont) one or two tabulations. How?

Sub Fonts()
Dim aFont
For Each aFont In FontNames
With Selection
.Font.Name = aFont
.TypeText Text:=aFont
.TypeText Text:="qwertyuiopasdf+ 1234567890="
.TypeParagraph
End With
Next aFont
End Sub

Thank you very much!
 
C

Cindy M.

Hi Avkokin,
There is code (below). I need to add after string (.TypeText
Text:=aFont) one or two tabulations. How?
In VBA you can use the keyword vbTab to indicate a Tab
character. Chr(9) is also valid. So:

.TypeText Text:="qwertyuiopasdf+ 1234567890=" _
& vbTab & Chr(9)


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun
17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
H

Helmut Weber

Hi Anton,
There is code (below). I need to add after string (.TypeText
Text:=aFont) one or two tabulations. How?

..TypeText Text:=aFont & Chr(9) & Chr(9)

but this only works satisfactorily,
if all of your fonts have about the same default width.
Otherwise use only one tab and try to position that.
You might need landscape format, too.
 
S

StevenM

To: A.V. Kokin,

Sub KokinFonts()
Dim aFont As Variant
For Each aFont In FontNames
With Selection
.Font.Name = aFont
.TypeText Text:=aFont & vbTab & "qwertyuiopasdf+ 1234567890=" &
vbCr
End With
Next aFont
End Sub

If you want two tabs add: & vbTab

For what its worth, see the following macro:

'
' List All Fonts: creates a new blank document & a table,
' and then inserts a sample of each available font.
'
Sub ListAllFonts()
Dim Index As Integer
Dim oTable As Table
Dim oRange As Range
Dim newDoc As Document
Dim nFonts As Long
Dim ptWidth As Single

Application.ScreenUpdating = False
nFonts = FontNames.count
Set newDoc = Documents.Add
With newDoc.PageSetup
ptWidth = PicasToPoints(51) - (.RightMargin + .LeftMargin)
End With
Set oTable = newDoc.Tables.Add(Selection.Range, nFonts + 1, 2)
With oTable
.Borders.Enable = False
.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
.rows.AllowBreakAcrossPages = False
.TopPadding = PicasToPoints(0.5)
.BottomPadding = PicasToPoints(0.5)
.Columns(1).PreferredWidth = ptWidth * 0.35
.Columns(2).PreferredWidth = ptWidth * 0.65
End With
With oTable.Cell(1, 1).Range
.Font.Name = "Arial"
.Font.Bold = True
.InsertAfter "Font Name"
End With
With oTable.Cell(1, 2).Range
.Font.Name = "Arial"
.Font.Bold = True
.InsertAfter "Font Example"
End With
For Index = 1 To nFonts
Application.StatusBar = "Adding " & nFonts & " Fonts to Table: " &
Index
With oTable.Cell(Index + 1, 1).Range
.Font.Name = "Arial"
.Font.Size = 12
.InsertAfter FontNames(Index)
End With
With oTable.Cell(Index + 1, 2).Range
.Font.Name = FontNames(Index)
.Font.Size = 12
.LanguageID = wdNoProofing
.InsertAfter "ABCDEFGHIJKLMNOPQRSTUVWXYZ" _
& vbCr & "abcdefghijklmnopqrstuvwxyz" _
& vbCr & "0123456789" _
& vbCr & "!#?$%&*()[]<>{}"
.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
End With
Next Index
oTable.Sort SortOrder:=wdSortOrderAscending
Set oRange = newDoc.Range.Sections(1).Headers(wdHeaderFooterPrimary).Range
newDoc.Fields.Add Range:=oRange, Type:=wdFieldPage

newDoc.Range.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers(1).Alignment = wdAlignPageNumberCenter
Application.ScreenUpdating = True
newDoc.Range(0, 0).Select
ActiveWindow.View.Type = wdPrintView
ActiveWindow.View.Zoom.PageFit = wdPageFitBestFit
End Sub

Steven Craig Miller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top