Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-29-2019, 07:40 PM
Guessed's Avatar
Guessed Guessed is offline Hyphen until the end of the row Windows 10 Hyphen until the end of the row Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,163
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default


OK, this code adds the line to every paragraph including table cells (except for the last para in the last cell of a table)
Code:
Sub TabToEndOfLine()
  Dim lngWidth As Long, lngLM As Long, lngRM As Long
  Dim oRng As Range, lngColWidth As Long
  Dim oPara As Paragraph
  On Error Resume Next
  For Each oPara In ActiveDocument.Paragraphs
    Set oRng = oPara.Range
    If oPara.Range.Information(wdWithInTable) = False Then
      lngColWidth = oRng.Sections(1).PageSetup.TextColumns.Width
    Else ' in a table
      lngColWidth = oRng.Cells(1).Width
    End If
    With oRng.ParagraphFormat.TabStops
      .ClearAll
      .Add Position:=lngColWidth, Alignment:=wdAlignTabRight, Leader:=2
    End With
    oRng.End = oRng.End - 1
    oRng.InsertAfter Chr(32) & vbTab
    DoEvents
  Next oPara
lbl_Exit:
  Set oRng = Nothing
  Set oPara = Nothing
  Exit Sub
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #2  
Old 10-30-2019, 01:05 AM
abc3132 abc3132 is offline Hyphen until the end of the row Windows 7 64bit Hyphen until the end of the row Office 2007
Novice
Hyphen until the end of the row
 
Join Date: Feb 2015
Posts: 24
abc3132 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
OK, this code adds the line to every paragraph including table cells (except for the last para in the last cell of a table)
Code:
Sub TabToEndOfLine()
  Dim lngWidth As Long, lngLM As Long, lngRM As Long
  Dim oRng As Range, lngColWidth As Long
  Dim oPara As Paragraph
  On Error Resume Next
  For Each oPara In ActiveDocument.Paragraphs
    Set oRng = oPara.Range
    If oPara.Range.Information(wdWithInTable) = False Then
      lngColWidth = oRng.Sections(1).PageSetup.TextColumns.Width
    Else ' in a table
      lngColWidth = oRng.Cells(1).Width
    End If
    With oRng.ParagraphFormat.TabStops
      .ClearAll
      .Add Position:=lngColWidth, Alignment:=wdAlignTabRight, Leader:=2
    End With
    oRng.End = oRng.End - 1
    oRng.InsertAfter Chr(32) & vbTab
    DoEvents
  Next oPara
lbl_Exit:
  Set oRng = Nothing
  Set oPara = Nothing
  Exit Sub
End Sub
WOW. It works perfectly well. Thanks both for your time...and abusing of your time what you should I change in the code above to do the way around?. I mean there is a document the end of the page where all the phrases´hyphens should be erased
Reply With Quote
Reply

Tags
hyphen



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyphen goes to next line DBlomgren Publisher 0 07-14-2016 06:46 PM
Bibliography Hyphen for repeat author grantgibson45 Word 3 02-25-2013 04:32 AM
Switching text on either side of hyphen nignog Word 1 01-23-2012 01:13 PM
Hyphen until the end of the row Auto change hyphen to em character not working gstech Word 1 10-08-2010 09:57 AM
Hyphen vs. en-dash tocuin Word 0 09-18-2009 10:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:19 AM.


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