tab character

G

gogo

hi. could someone tell me how can i put tab character in a variable
i need to replace tab signs with indentions. i solve this with positioning in the begining of the lin
and count the tab sign, then select & delete them, and then indent paragraph as many times a
tab sign i counted. it should work but i need that tab sig

tried wit "^t" - didn't wor

tnx
 
P

Peter Hewett

Hi

This is an alternative approach that you may care to try:

Public Sub ReplaceTabsWithIndent()
Dim prgItem As Word.Paragraph
Dim rngStart As Word.Range
Dim rngAfterTabs As Word.Range
Dim lngParagraphCount As Long
Dim lngIndents As Long

' Check each paragraph for leading Tabs
For Each prgItem In ActiveDocument.Paragraphs
Set rngStart = prgItem.Range
rngStart.Collapse wdCollapseStart
Set rngAfterTabs = rngStart.Duplicate
lngParagraphCount = rngAfterTabs.MoveStartWhile(vbTab)

' Delete any Tab characters found and
' add appropriate number of indents
If lngParagraphCount > 0 Then
rngStart.End = rngAfterTabs.Start
rngStart.Delete

For lngIndents = 1 To lngParagraphCount
rngStart.Paragraphs(1).Indent
Next
End If
Next
End Sub


HTH + Cheers - Peter
 
G

gogo

tnx to all. solved. here's the algoritham
b = 0
Selection.HomeKey Unit:=wdLine
If (Selection.ParagraphFormat.FirstLineIndent) Then
Selection.ParagraphFormat.FirstLineIndent = False
b = b + 1
End If
Do
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If ((Selection.Text) = Chr(9)) Then
b = b + 1
Selection.MoveRight Unit:=wdCharacter, Count:=1
End If
Loop While ((Selection.Text) = Chr(9))
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
For i = 1 To b
Selection.Paragraphs.Indent
Next i
 

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