Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 02-24-2014, 09:44 PM
macropod's Avatar
macropod macropod is offline Convert indent to tabs a document converted from PDF Windows 7 32bit Convert indent to tabs a document converted from PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try something along the following lines:
Code:
Sub Demo()
Application.ScreenUpdating = True
Dim i As Long
With Selection
  For i = 1 To .Paragraphs.Count
    With .Paragraphs(i).Range.Characters.First
      Select Case Int(PointsToInches(.Information(wdHorizontalPositionRelativeToTextBoundary)) * 4)
        Case 1: .InsertBefore vbTab
        Case 2: .InsertBefore vbTab & vbTab
        Case 3: .InsertBefore vbTab & vbTab & vbTab
        Case 4: .InsertBefore vbTab & vbTab & vbTab & vbTab
        Case 5: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab
        Case 6: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
        Case 7: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
        Case 8: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
        Case 9: .InsertBefore vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
      End Select
    End With
  Next
  .ParagraphFormat.Alignment = wdAlignParagraphLeft
  .ClearParagraphAllFormatting
End With
Application.ScreenUpdating = True
End Sub
or:
Code:
Sub Demo()
Application.ScreenUpdating = True
Dim i As Long, j As Long, StrTmp As String
With Selection
  For i = 1 To .Paragraphs.Count
    StrTmp = vbNullString
    With .Paragraphs(i).Range.Characters.First
      For j = 0 To Int(PointsToInches(.Information(wdHorizontalPositionRelativeToTextBoundary)) * 4)
        StrTmp = StrTmp & vbTab
      Next
      .InsertBefore StrTmp
    End With
  Next
  .ParagraphFormat.Alignment = wdAlignParagraphLeft
  .ClearParagraphAllFormatting
End With
Application.ScreenUpdating = True
End Sub
As coded, the macros apply tabs to a selected block of text. You may need to play around with the '* 4' and even subtract a constant value from than line to get the kind of indenting you desire. I'd suggest going even further: Define a 'code' Style with whatever final tab-stop positions you'd prefer and apply that to the range after the '.ClearParagraphAllFormatting' line. The second macro is more flexible, as it accommodates any level of indenting.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 02-24-2014 at 09:49 PM. Reason: Alternative macro
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert indent to tabs a document converted from PDF Convert word document to pdf Catty Word VBA 1 12-11-2013 03:57 PM
Words in my document were converted to numbers???? MikeD23 Word 1 08-26-2012 11:09 AM
Can you see how much time I worked on Word 2007/2010 document when converted to PDF? Papa Bear Word 1 08-14-2012 05:14 AM
My plain text post got converted to rich text in a reply, how to convert it back? david.karr Outlook 0 01-05-2012 09:46 AM
Convert indent to tabs a document converted from PDF PDF to Word(.doc) document not convert correctly gonner Word 1 09-10-2011 03:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:38 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft