Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 12-09-2023, 09:46 AM
RobiNew RobiNew is offline Separate strings in a text file Windows 10 Separate strings in a text file Office 2016
Competent Performer
Separate strings in a text file
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default

I managed to make it work correctly, provisionally on a single instance of the text mentioned above.
Perhaps someone can make it less clumsy.
Code:
Sub ThreeStrings()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
        .Text = "<img width"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = False
While .Execute
oRng.MoveEndUntil Cset:="><"
VarStrg1 = oRng
'MsgBox VarStrg1
oRng.Collapse
oRng.MoveEndUntil Cset:=" "
oRng.Move Unit:=wdCharacter, Count:=2
oRng.MoveEndUntil Cset:=" "
VarWd = oRng
'MsgBox VarWd
oRng.Move Unit:=wdCharacter, Count:=2
oRng.MoveEndUntil Cset:=" "
VarHi = oRng
'MsgBox VarHi
Set oRng = ActiveDocument.Range
With oRng.Find
        .Text = "<img width"
        .Replacement.Text = ""
        .Forward = False
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = False
        .Execute
End With
oRng.MoveEndUntil Cset:="><"
oRng.Delete
Goto End
Wend
    End With
End:
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to hide/delete slides based on keyword in a separate text file based on AND|OR condition? rupd911 PowerPoint 0 02-22-2021 08:22 AM
Separate strings in a text file Auto Save Every Page(s) as a separate file, and name each new file automatically by the first line? commissarmo Word VBA 3 03-14-2015 12:53 AM
Separate strings in a text file Copying a part of a docx file as a separate file officeboy09 Word 6 09-26-2014 05:15 PM
Separate strings in a text file Search Multiple strings and create new word file subodhgupta Word 4 05-22-2014 03:34 AM
Separate strings in a text file update style of all strings available between two specific strings vikrantkale Word 1 03-28-2011 06:13 PM

Other Forums: Access Forums

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