Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-30-2023, 09:26 AM
RobiNew RobiNew is offline Getting the last of three names/words Windows 10 Getting the last of three names/words Office 2016
Competent Performer
Getting the last of three names/words
 
Join Date: Sep 2023
Posts: 231
RobiNew is on a distinguished road
Default

Thank you, Vivka! Obviously, I was a bit confused while trying to write that code,
Reply With Quote
  #2  
Old 12-30-2023, 09:39 AM
vivka vivka is offline Getting the last of three names/words Windows 7 64bit Getting the last of three names/words Office 2016
Expert
 
Join Date: Jul 2023
Posts: 305
vivka is on a distinguished road
Default

You are welcome, RobiNew!
Reply With Quote
  #3  
Old 01-01-2024, 11:26 AM
RobiNew RobiNew is offline Getting the last of three names/words Windows 10 Getting the last of three names/words Office 2016
Competent Performer
Getting the last of three names/words
 
Join Date: Sep 2023
Posts: 231
RobiNew is on a distinguished road
Default

Hi, Vivka! I'm trying to move until a specific character, but my code seems to be wrong. Can you help? Thanks!
Code:
Sub MovingChr()
Set oRng = ActiveDocument.Range
    With oRng.Find
    .Text = "<p class=MyPar>"
    .Execute
    End With
oRng.Collapse wdCollapseEnd
'If Selection is between > and < then move on to next <
If oRng.Characters.First = "<" Then
oRng.Collapse wdCollapseEnd
oRng.Select
      oRng.MoveEndUntil Cset:="<"
          oRng.Select
End If
End Sub
Reply With Quote
  #4  
Old 01-01-2024, 12:54 PM
vivka vivka is offline Getting the last of three names/words Windows 7 64bit Getting the last of three names/words Office 2016
Expert
 
Join Date: Jul 2023
Posts: 305
vivka is on a distinguished road
Default

Hi, RobiNew! Try this:
Code:
Sub MovingChr()
Set oRng = ActiveDocument.range
    With oRng.Find
    .text = "<p class=MyPar>"
    .Execute
    End With
    If oRng.Characters.Last.Next Like "<" Then
        oRng.MoveEnd unit:=wdCharacter, count:=1
        oRng.MoveEndUntil Cset:="<"
        oRng.Collapse wdcollapsend
        oRng.Select 'to see the cursor psn; if you are going to work with oRng, this line can be deleted
    End If
End Sub
or this:

Code:
Sub MovingChr()
Set oRng = ActiveDocument.range
    With oRng.Find
    .text = "<p class=MyPar>"
    .Execute
    End With
    oRng.Collapse wdcollapsend
    If oRng.Characters.First Like "<" Then
        oRng.Move unit:=wdCharacter, count:=1
        oRng.MoveUntil Cset:="<"
        oRng.Select 'to see the cursor psn; if you are going to work with oRng, this line can be deleted
    End If
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Foreign words/names Read Aloud HanselM Word 1 05-01-2023 09:36 AM
Getting the last of three names/words Removing microsoft build-in style names - display of style names in styles gallery changed Firebody Word 8 03-06-2022 08:22 AM
How to find (highlight) two and more words in a list of 75k single words in Word 2010 Usora Word 8 05-29-2018 03:34 AM
Need to extract domain names containing only specific words (MAJOR BULK) Maxwell314 Excel 4 12-08-2014 05:10 PM
How to enter names in Resource Pool/names pstein Project 1 03-26-2012 07:37 AM

Other Forums: Access Forums

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