ImageFormat Property

Microsoft Publisher Visual Basic

Show All Show All

ImageFormat Property

Returns a PbImageFormat constant that represents the image format of a picture as determined by Microsoft® Windows® Graphics Device Interface (GDI+). Read-only.

PbImageFormat can be one of these PbImageFormat constants.
pbImageFormatCMYKJPEG (See Remarks.)
pbImageFormatDIB (See Remarks.)
pbImageFormatEMF (See Remarks.)
pbImageFormatGIF (See Remarks.)
pbImageFormatJPEG
pbImageFormatPICT (See Remarks.)
pbImageFormatPNG
pbImageFormatTIFF
pbImageFormatUNKNOWN
pbImageFormatWMF

expression.ImageFormat()

expression    Required. An expression that returns a PictureFormat object.

Remarks

The ImageFormat property applies to the original picture, rather than the placeholder picture, if there is one.

The ImageFormat property indicates the format of the picture after it has been imported into the Windows environment, rather than its original file format. If the picture's file format is not natively supported by the Windows operating system, the picture is converted to an analogous format that is natively supported. As a result, the pbImageFormatCMYKJPEG, pbImageFormatDIB, pbImageFormatEMF, pbImageFormatGIF, and pbImageFormatPICT constants will rarely, if ever, be returned. Consult the table below for specific file format conversions.

File format Constant returned
.bmp, .dib, .gif, .pict pbImageFormatPNG
.emf, .eps, .epfs pbImageFormatWMF
CMYK .jfif, .jpeg, .jpg pbImageFormatJPEG

Windows GDI+ is the portion of the Windows XP operating system and the Windows Server 2003 operating system that provides two-dimensional vector graphics, imaging, and typography.

Example

The following example prints a list of the .jpg and .jpeg images present 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
                
                    If .ImageFormat = pbImageFormatJPEG Then
                        Debug.Print .Filename
                    End If
                
                End If
            End With
            
        End If
        
    Next shpLoop
Next pgLoop