Filename Property

Microsoft Publisher Visual Basic

Filename Property

Returns a String that represents the file name of the specified picture or OLE object. Read-only.

expression.Filename()

expression    Required. An expression that returns a PictureFormat object.

Remarks

For linked pictures and OLE objects, the returned string represents the full path and file name of the picture. For embedded pictures and OLE objects, the returned string represents the file name only.

To determine whether a shape represents a linked picture, use either the Type property of the Shape object, or the IsLinked property of the PictureFormat object.

Example

The following example returns selected image properties for each picture in the active publication.

    Dim pgLoop As Page
Dim shpLoop As Shape

For Each pgLoop In ActiveDocument.Pages
    For Each shpLoop In pgLoop.Shapes
        If shpLoop.Type = pbPicture Or shpLoop.Type = pbLinkedPicture Then
        
            With shpLoop.PictureFormat

                   If .IsEmpty = msoFalse Then

                        Debug.Print "File Name: " & .Filename
                        Debug.Print "Horizontal Scaling: " & .HorizontalScale & "%"
                        Debug.Print "Vertical Scaling: " & .VerticalScale & "%"
                        Debug.Print "File size in publication: " & .FileSize & " bytes"

                   End If

            End With
        End If
    Next shpLoop
Next pgLoop