![]() |
|
#1
|
||||
|
||||
|
I have in my document damaged images that I want to replace.
I want to search each image in document, edit the hyperlink then go to that hyperlink, get the new Image and replace with old one. Here is steps I want to perform 1. Search for images 2. If found, see if it contains hyperlink. 3. If found, want to see weather hyperlink looks like this about://*URLwithoutHTTP* 4. If matches want to replace about with HTTP 5. replace found image with image from url with scaling fit to table. |
|
#2
|
||||
|
||||
|
Here's some code to get you started. I believe you already have code for querying websites and retrieving content from them.
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim iShp As InlineShape
For Each iShp In ActiveDocument.InlineShapes
With iShp.Range
If .Hyperlinks.Count = 1 Then
.Hyperlinks(1).Address = Replace(.Hyperlinks(1).Address, "about://", "HTTP//")
End If
End With
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
||||
|
||||
|
Thanks for quick reply.
I don't know everything about "querying websites and retrieving content from them" Just learned from earlier posts of related search. Anyway I will try for this one as well. |
|
#4
|
||||
|
||||
|
I don't know why but ActiveDocument.InlineShapes doesn't find InlineShapes for my document.
Anyhow ^g is working. I tried this code from various earlier suggestions. Code:
Sub BrokenImages2()
Application.ScreenUpdating = False
Dim StrTxt As String, HttpReq As Object, i As Long
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^g"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = False
.Execute
End With
Do While .Find.Found
If .Hyperlinks.Count > 0 Then
s = .Hyperlinks(1).Address
MsgBox s
If InStr(s, "about") = 1 Then
s = Replace(.Hyperlinks(1).Address, "about", "HTTP")
MsgBox s
With Dialogs(wdDialogInsertPicture)
.Name = s
.Execute
End With
End If
End If
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
End Sub
How to replace images that found with url images? |
|
#5
|
||||
|
||||
|
Please Help me with this.
Having incomplete knowledge of process is creating huge problem and waste of time. Code:
Sub BrokenImg()
Application.ScreenUpdating = False
Dim StrTxt As String, HttpReq As Object, i As Long
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
Set rng1 = ActiveDocument.Range
With rng1
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^g"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = False
.Execute
End With
Do While .Find.Found
Set rng2 = ActiveDocument.Range(rng1.End, ActiveDocument.Range.End)
If .Hyperlinks.Count > 0 Then
s = .Hyperlinks(1).Address
MsgBox s
If InStr(s, "about") = 1 Then
s = Replace(.Hyperlinks(1).Address, "about", "https")
MsgBox s
rng2.InlineShapes.AddPicture FileName:= _
s _
, LinkToFile:=False, SaveWithDocument:=True
End If
End If
End With
Set rng2 = Nothing
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Set rng1 = Nothing
End Sub
Document is at: https://sites.google.com/site/rtsk2015/fo https://sites.google.com/site/rtsk20...edirects=0&d=1 |
|
#6
|
||||
|
||||
|
While recording macro to find the graphics, while selecting it gives
Code:
ActiveDocument.Shapes.Range(Array("Rectangle 3"))
End of efforts from My side. |
|
| Tags |
| word vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Missing or damaged XLLEX.DLL
|
Mikets | Office | 1 | 01-02-2014 11:49 PM |
| Searhc for Hyperlinked Word and replace with plain text or nothing | somniloquist | Word | 3 | 10-04-2011 02:33 AM |
| Why isn't my hyperlinked word text hyperlinked when I convert it to pdf? | Obisco | Word | 0 | 12-10-2010 01:58 PM |
| copy-pasting hyperlinked images: work only at the edges | Xuanzang | PowerPoint | 0 | 12-07-2010 02:35 AM |
how find and replace images
|
pol2005 | Word | 2 | 06-10-2010 10:24 AM |