0

Web リンクを持つ vba の文字列があります。ただし、文字列が Microsoft Word ページに表示される場合。テキストが折り返され、リンクが壊れています。リンクの開始位置と停止位置を VBA が認識できるようにするにはどうすればよいですか?

文字列は次のようになります。

Dim My_MSG As String 
My_MSG = "Full company list can be found at finance.yahoo.com/blogs/hot-stock-minute/… by yahoo' by yourclients."

この文字列が単語テーブルに入力されると、リンクは完全なリンクを認識しません

4

1 に答える 1

0

Word はリンクを自動的に認識しません。Hyperlinks.Add を使用して、ハイパーリンクを挿入できます。これが例です。

Sub AddTextwHyperlink()
   Dim objDoc As Document
   Dim objRng As Range

   Set objDoc = ActiveDocument
   Set objRng = Selection.Range

   'Adds text before link.
   objRng.InsertAfter "Full company list can be found at "

   'Collapses range so that hyperlink will be added after text.
   objRng.Collapse wdCollapseEnd

   'Adds hyperlink and sets the range to start after the hyperlinked text.
   objRng.start = objDoc.Hyperlinks.Add(Anchor:=objRng, Address:="http://finance.yahoo.com/blogs/hot-stock-minute/").Range.End

   'Adds the rest of the text.
   objRng.InsertAfter " by yahoo' by yourclients."

End Sub
于 2013-11-01T21:38:39.630 に答える