我能够通过UserForm从用户输入填充Word文档的书签位置。Word UserForm VBA:书签超链接
我想要做的是将输入的文本转换为超链接。
下面的代码SNIPPIT用来插入文本到适当的位置:
Private Sub CommandButton1_Click()
Dim benchmarkURL As Range
Set benchmarkURL = ActiveDocument.Bookmarks("benchmark").Range
benchmarkURL.Text = Me.benchmarkURLTextBox.Value
ActiveDocument.Bookmarks.Add "benchmark", benchmarkURL
Me.Repaint
'Update the fields to populate the references of the bookmarks
UpdateAllFields
UserForm1.Hide
End Sub
我尝试以下,没有工作:
Private Sub CommandButton1_Click()
Dim benchmarkURL As Range
Set benchmarkURL = ActiveDocument.Bookmarks("benchmark").Range
benchmarkURL.Text = Me.benchmarkURLTextBox.Value
Hyperlinks.Add(ActiveDocument.Bookmarks.Add "benchmark", benchmarkURL)
Me.Repaint
'Update the fields to populate the references of the bookmarks
UpdateAllFields
UserForm1.Hide
End Sub
任何意见将非常感激
在此先感谢