我有一组 Word 文档,其中包含许多非嵌入图像。图像指向的 url 不再存在。我想以编程方式将 url 的域名更改为其他名称。我该如何在 Java 或 Python 中执行此操作?
最佳答案
这就是 VBA 的用途:
Sub HlinkChanger()
Dim oRange As Word.Range
Dim oField As Field
Dim link As Variant
With ActiveDocument
.Range.AutoFormat
For Each oRange In .StoryRanges
For Each oFld In oRange.Fields
If oFld.Type = wdFieldHyperlink Then
For Each link In oFld.Result.Hyperlinks
// the hyperlink is stored in link.Address
// strip the first x characters of the URL
// and replace them with your new URL
Next link
End If
Next oFld
Set oRange = oRange.NextStoryRange
Next oRange
关于java - 如何以编程方式更改Word文档中图像的URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/428308/