PictureFormat.Replace メソッド (Publisher)

指定した図に置き換えられます。 Nothing を返します。

構文

Replace (PathNameInsertAs)

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

パラメーター

名前 必須 / オプション データ型 説明
PathName 必須 String 指定した図と置き換えるファイルの名前およびパスを指定します。
InsertAs 省略可能 PbPictureInsertAs 画像ファイルをリンクして文書に挿入するか、または埋め込んで文書に挿入するかを指定します。 Microsoft Publisher タイプ ライブラリで宣言されている PbPictureInsertAs クラスの定数の 1 つを指定できます。既定値は pbPictureInsertAsOriginalState です

注釈

文書に挿入された後に変更されているリンクされた図のファイルを更新するのにには、 Replace メソッドを使用します。

LinkedFileStatus プロパティを使用して、リンクされた画像が変更されているかどうかを判断します。

次の使用例は、作業中の文書にある特定の図のすべてのオカレンスを別の図に置き換えます。

Sub ReplaceLogo() 
 
Dim pgLoop As Page 
Dim shpLoop As Shape 
Dim strExistingArtName As String 
Dim strReplaceArtName As String 
 
 
strExistingArtName = "C:\path\logo 1.bmp" 
strReplaceArtName = "C:\path\logo 2.bmp" 
 
For Each pgLoop In ActiveDocument.Pages 
 For Each shpLoop In pgLoop.Shapes 
 If shpLoop.Type = pbLinkedPicture Then 
 
 With shpLoop.PictureFormat 
 If .Filename = strExistingArtName Then 
 .Replace (strReplaceArtName) 
 End If 
 End With 
 
 End If 
 
 Next shpLoop 
Next pgLoop 
 
End Sub

次の使用例は、リンクされている各図を調べて、文書に挿入された後でリンク ファイルが変更されているかどうか判断します。 変更されていれば、ファイルをそれ自体で置き換えることにより更新します。

Sub UpdateModifiedLinkedPictures() 
 
Dim pgLoop As Page 
Dim shpLoop As Shape 
Dim strPictureName As String 
 
 
For Each pgLoop In ActiveDocument.Pages 
 For Each shpLoop In pgLoop.Shapes 
 If shpLoop.Type = pbLinkedPicture Then 
 
 With shpLoop.PictureFormat 
 If .LinkedFileStatus = pbLinkedFileModified Then 
 strPictureName = .Filename 
 .Replace (strPictureName) 
 End If 
 End With 
 
 End If 
 Next shpLoop 
Next pgLoop 
 
End Sub

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

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