Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Tue, 19 Aug 2008 04:47:59 -0700 (PDT),    group: microsoft.public.word.vba.general        back       


How to add 2 tabulations after string?   
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!
date: Tue, 19 Aug 2008 04:47:59 -0700 (PDT)   author:   avkokin

Re: How to add 2 tabulations after string?   
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 :-)
date: Tue, 19 Aug 2008 14:31:53 +0200   author:   Cindy M.

RE: How to add 2 tabulations after string?   
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.

-- 
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Word 2002, Windows XP (german versions)
date: Tue, 19 Aug 2008 05:35:17 -0700   author:   Helmut Weber

RE: How to add 2 tabulations after string?   
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
"avkokin" wrote:

> 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!
> 
>
date: Tue, 19 Aug 2008 05:37:01 -0700   author:   StevenM stevencraigmiller(at)comcast(dot)net

Re: How to add 2 tabulations after string?   
Thank you very much!
Sincerely, Anton.
date: Tue, 19 Aug 2008 10:10:43 -0700 (PDT)   author:   avkokin

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us