2009-01-09 48 views

回答

1

這是這種東西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 
0

你要做到這一點在Java或Python。嘗試OpenOffice。 在OpenOffice中,您可以將Java或Python代碼作爲「Makro」插入。

我相信會有更改圖片網址的可能性。

0

VBA答案是最接近的,因爲這最好使用Microsoft Word COM API完成。不過,你可以在Python中使用它。我自己使用它來從數百個Word文檔的表單中將數據導入到數據庫中。

This article解釋了基本知識。請注意,即使它爲WordDocument COM對象創建了一個類封裝器,如果您不想這樣做,也不需要執行此操作。您可以直接訪問COM API。

有關WordDocument COM API的文檔,請打開Word文檔,按Alt-F11打開VBA編輯器,然後按F2查看對象瀏覽器。這使您可以瀏覽所有對象及其提供的方法。 Python和COM對象模型is found here的介紹。

相關問題