Microsoft Word VBA 将网页 link 插入文档中的文本框

Microsoft Word VBA insert web link to text box in document

有什么方法可以使用 VBA 将 html link 插入文本框?我创建了一个带有文本框的对话框,我想将文本转换为网页 link,然后将其插入文档中的文本框。

Dim WO_Box1 As Shape
Set WO_Box1 = ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, Left:=17, Top:=125, Width:=106.5, Height:=19)
WO_Box1.TextFrame.TextRange.Font.Name = "Tahoma"
WO_Box1.TextFrame.TextRange.Font.Size = "9"
WO_Box1.TextFrame.TextRange.Text = TextBox1.Text
WO_Box1.TextFrame.TextRange.Hyperlinks.Add Anchor:=WO_Box1.TextFrame.TextRange, Address:=TextBox1.Text, TextToDisplay:=TextBox1.Text

锚点 是您正在使用的文本框。您可以为 TextToDisplay 使用任何文本,但 Address 应该分配给实际的超链接 url.