次の方法で共有


Hyperlink.CreateURL メソッド (Visio)

ハイパーリンクの絶対アドレスを、完全修飾の形式または標準の形式 (オプション) で返します。

構文

CreateURL( _CanonicalForm_ )

Hyperlink オブジェクトを表す変数。

パラメーター

名前 必須 / オプション データ型 説明
CanonicalForm 必須 Integer 標準の形式で取得する場合は、True (ゼロ以外)、それ以外の場合は、False (0) です。

戻り値

文字列

注釈

Hyperlink オブジェクトの CreateURL メソッドを使用すると、ハイパーリンクのべース アドレスを基準とする相対 URL を確認できます。

標準の形式を使用した場合、CreateURL メソッドでは、ハイパーリンクに URL 標準化規則が適用されます。 標準化を行うとき、URL エンコードの対象となるのはスペースのみです。 ポート 80 は HTTP URL と見なされ、標準化のときに削除されます。 たとえば、URL "https://www.microsoft.com:80/"は "https://www.microsoft.com/" として返されます。一方 https://www.microsoft.com:1000/"、 は として 返されます。は変更されません。

CreateURL メソッドが返す結果の例を、次に示します。

Address = "https://www.microsoft.com/" 
CreateURL(False) returns "https://www.microsoft.com/" 
 
Address = "C:\My Documents\Spreadsheet.XLS" 
CreateURL(False) returns "file://C:\My Documents\Spreadsheet.XLS" 
CreateURL(True) returns "file://C:\My%20Documents\Spreadsheet.XLS" 
 

相対パスの例

Assume : Document.HyperlinkBase = "https://www.microsoft.com/widgets/" 
Address = "../file.htm" 
CreateURL(False) returns "https://www.microsoft.com/file.htm" 
 

次の例は、CreateURL メソッドを使用してハイパーリンクのベース アドレスを基準とする相対 URL を確認できます。 このマクロを実行する前に、 drive\folder\subfolder をコンピューター上の有効なファイル パスに置き換え、 アドレス を有効なインターネットまたはイントラネット アドレスに置き換え、 drawing.vsd をコンピューター上の有効なファイルに置き換えます。

 
Sub CreateURL_Example() 
 
 Dim vsoShape As Visio.Shape 
 Dim vsoHyperlink As Visio.Hyperlink 
 
 'Draw a rectangle shape on the active page 
 Set vsoShape = ActivePage.DrawRectangle(1, 2, 2, 1) 
 
 'Add a hyperlink to a shape 
 Set vsoHyperlink = vsoShape.AddHyperlink 
 
 'Allow relative hyperlink addresses 
 ActiveDocument.HyperlinkBase = "drive :\folder \subfolder " 
 
 'Return a relative address 
 vsoHyperlink.Address = "..\drawing.vsd " 
 
 'Print the resulting URLs to the Debug window 
 'to show how the relative path is derived 
 'from the base path and the difference 
 'between canonical and non-canonical forms 
 Debug.Print vsoHyperlink.CreateURL(False) 
 Debug.Print vsoHyperlink.CreateURL(True) 
 
 'Return an absolute address 
 vsoHyperlink.Address = "https://address " 
 
 'Print the resulting URL to the Debug window 
 Debug.Print vsoHyperlink.CreateURL(False) 
 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。