Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2018, 07:06 AM
gmayor's Avatar
gmayor gmayor is offline Add an s at the end of the current word Windows 10 Add an s at the end of the current word Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I think the following should do it. As you have discovered, what you might think of as a word and what VBA thinks is a word do not necessarily coincide.


Code:
Sub Pluriel()
Dim oRng As Range
Dim lngCase As Long
    Set oRng = Selection.Words(1)
    lngCase = oRng.Case
    oRng.MoveEndWhile Chr(32) & Chr(160), wdBackward
    oRng.Collapse 0
    If lngCase = 1 Then
        oRng.Text = "S"
    Else
        oRng.Text = "s"
    End If
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #2  
Old 02-01-2018, 07:14 AM
gloub gloub is offline Add an s at the end of the current word Windows 7 64bit Add an s at the end of the current word Office 2003
Novice
Add an s at the end of the current word
 
Join Date: Feb 2018
Location: Paris, France
Posts: 29
gloub is on a distinguished road
Default

Many thanks, that's perfect !
(you even went beneath my expectations while managing the case)
Brilliant !





And now, I have to figure out how the code works.....
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add an s at the end of the current word Problem getting filename and directory of current word doc. gazeranco Word VBA 8 10-29-2016 12:13 AM
Add an s at the end of the current word Where can I see the current hidden word properties values in Word 2007? pstein Word 3 08-15-2012 05:08 AM
Add an s at the end of the current word How to call current PC date and/or current PC year KIM SOLIS Excel 2 11-04-2011 06:09 PM
Add an s at the end of the current word What “style” is used by the current line. Word 2007. persist Word 2 04-07-2010 09:52 PM
Add an s at the end of the current word Auto insert current month's name and current year Styler001 Word 4 01-25-2010 06:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:01 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