本文介绍了将超链接和带书签的单词转换为html< a>使用VBA宏在Word中标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有书签的单词,如"单击此处".如何使用VBA宏将其转换为HTML锚标记

I have a word with bookmarked like "click here".How should it be converted to HTML anchor tag using VBA macros

<a href="https://stackoverflow.com/">click here</a>

然后,如果一个带有内部或外部书签的单词,如何转换文本,例如,在诸如"t20 CTRL +单击链接"之类的单词上出现一个弹出框

And then, if a word with bookmarked internal or external, how to convert the text, for e.g., a popup box appears on the word like "t20 CTRL+click to Link"

<a href="t20">Introduction Matthew Davidson</a>

推荐答案

实际上,我想从文本中提取超链接.所以我用下面的代码解决了这个问题.

Actually, I would like to extract the hyperlinks from text. So I have solved the question with below the code.

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
oFld.Select
Selection.InsertBefore "<a href=""" + link.Address + """>"
Selection.InsertAfter "</a>"
Next link
End If
Next oFld
Set oRange = oRange.NextStoryRange
Next oRange
End With
End Sub

感谢您的支持...

这篇关于将超链接和带书签的单词转换为html&lt; a&gt;使用VBA宏在Word中标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-22 04:06