![]() |
|
#1
|
|||
|
|||
|
I have a text file with several sequences of this type:
<p class=NonNrPar align=center style='text-align:center;line-height: normal'><img width=453 height=255 id="Immagine 1" src="E_DIME_ORIG_file/image001.jpg"></p> I'm trying to write a macro that will 1) find the string |<img .... ><| (eventually to be deleted); 2) return the string |width=and its digits|; 3) return the string |height=and its digits|. The code here below doesn't work. Should I try Split? Can someone help? Thanks! 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
While .Execute
oRng.MoveEndUntil Cset:="><"
MyString = oRng
MsgBox MyString '1. this one works
'oRng.Delete
oRng.Collapse wdCollapseStart
oRng.MoveEndUntil Cset:=" h", Count:=wdForward 'this doesn't work
VarWd = oRng
MsgBox VarWd
oRng.Move Unit:=wdCharacter, Count:=1
'oRng.Select
oRng.Collapse wdCollapseEnd
oRng.MoveUntil oRng Like "^# " 'this doesn't work
VarHi = oRng
MsgBox VarHi
Wend
End With
End Sub
|
|
|
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 |
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 |
Copying a part of a docx file as a separate file
|
officeboy09 | Word | 6 | 09-26-2014 05:15 PM |
Search Multiple strings and create new word file
|
subodhgupta | Word | 4 | 05-22-2014 03:34 AM |
update style of all strings available between two specific strings
|
vikrantkale | Word | 1 | 03-28-2011 06:13 PM |