code_junkie

How to programmatically change urls of images in word documents

Nov 13th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Sub HlinkChanger()
  2. Dim oRange As Word.Range
  3. Dim oField As Field
  4. Dim link As Variant
  5. With ActiveDocument
  6. .Range.AutoFormat
  7. For Each oRange In .StoryRanges
  8. For Each oFld In oRange.Fields
  9. If oFld.Type = wdFieldHyperlink Then
  10. For Each link In oFld.Result.Hyperlinks
  11. // the hyperlink is stored in link.Address
  12. // strip the first x characters of the URL
  13. // and replace them with your new URL
  14. Next link
  15. End If
  16. Next oFld
  17. Set oRange = oRange.NextStoryRange
  18. Next oRange
Add Comment
Please, Sign In to add comment