Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-02-2015, 11:10 PM
PRA007's Avatar
PRA007 PRA007 is offline How to replace damaged hyperlinked images from web. Windows 7 64bit How to replace damaged hyperlinked images from web. Office 2010 32bit
Competent Performer
How to replace damaged hyperlinked images from web.
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default How to replace damaged hyperlinked images from web.

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.
Reply With Quote
  #2  
Old 12-03-2015, 12:08 AM
macropod's Avatar
macropod macropod is offline How to replace damaged hyperlinked images from web. Windows 7 64bit How to replace damaged hyperlinked images from web. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,385
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 12-03-2015, 12:21 AM
PRA007's Avatar
PRA007 PRA007 is offline How to replace damaged hyperlinked images from web. Windows 7 64bit How to replace damaged hyperlinked images from web. Office 2010 32bit
Competent Performer
How to replace damaged hyperlinked images from web.
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 12-03-2015, 02:01 AM
PRA007's Avatar
PRA007 PRA007 is offline How to replace damaged hyperlinked images from web. Windows 7 64bit How to replace damaged hyperlinked images from web. Office 2010 32bit
Competent Performer
How to replace damaged hyperlinked images from web.
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

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
This is inserting images at selection.
How to replace images that found with url images?
Reply With Quote
  #5  
Old 12-04-2015, 04:35 AM
PRA007's Avatar
PRA007 PRA007 is offline How to replace damaged hyperlinked images from web. Windows 7 64bit How to replace damaged hyperlinked images from web. Office 2010 32bit
Competent Performer
How to replace damaged hyperlinked images from web.
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

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
In this code, inserting starts at whenever selection is followed by .found. How to start inserting at .found.

Document is at:
https://sites.google.com/site/rtsk2015/fo
https://sites.google.com/site/rtsk20...edirects=0&d=1
Reply With Quote
  #6  
Old 12-04-2015, 09:44 PM
PRA007's Avatar
PRA007 PRA007 is offline How to replace damaged hyperlinked images from web. Windows 7 64bit How to replace damaged hyperlinked images from web. Office 2010 32bit
Competent Performer
How to replace damaged hyperlinked images from web.
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

While recording macro to find the graphics, while selecting it gives
Code:
ActiveDocument.Shapes.Range(Array("Rectangle 3"))
This type of objects looks like impossible to work with as .hyperlinks and do while .find.found gives error.
End of efforts from My side.
Reply With Quote
Reply

Tags
word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to replace damaged hyperlinked images from web. 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 to replace damaged hyperlinked images from web. how find and replace images pol2005 Word 2 06-10-2010 10:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:44 AM.


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