![]() |
|
|
|
#1
|
|||
|
|||
|
Thank you,Vivka! That's a nice variant, but if you Find 'width' you might land on an non-image string;
and ^#^#^# could be different (e.g.: ^#^#). The code should operate within the image string mentioned in post 7. |
|
#2
|
|||
|
|||
|
Then what about this:
Code:
Sub Test()
Dim oRng As range
Dim oRngD As range
Dim oRngDD As range
Dim vWd As Variant
Dim vHi As Variant
Set oRng = ActiveDocument.range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.text = "\<img width*\>"
.Replacement.text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
If .Execute Then
Set oRngD = oRng.Duplicate
Set oRngDD = oRng.Duplicate
.text = "width=" & "[0-9]@ "
.MatchWildcards = True
If .Execute Then vWd = oRng
With oRngD.Find
.text = "height=" & "[0-9]@ "
.MatchWildcards = True
If .Execute Then vHi = oRng
End With
End If
End With
oRngDD.Delete
MsgBox "'" & vWd & "'" & vbCr & "'" & vHi & "'"
lbl_Exit:
Set oRng = Nothing
Set oRngD = Nothing
Set oRngDD = Nothing
End Sub
1) Word & Height are remembered with trailing space, which I think is insignificant; 2) If you want to delete the final '<', change .text = "\<img" & "*\>" to .text = "\<img" & "*\>\<" Last edited by vivka; 12-10-2023 at 09:31 AM. |
|
|
|
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 |