Name
LoadPicture Function
Syntax
LoadPicture(picturename
)
picturename
Use: Required
Data Type: String
The path and filename of the picture file.
Return Value
A StdPicture object.
Description
Loads a picture object.
Rules at a Glance
picturename
consists of an optional path along with the name of a supported image file. If the path component ofpicturename
is omitted, the VBScript runtime engine attempts to find the image in the script’s current directory.picturename
can be a bitmap (.bmp), enhanced metafile (.emf ), icon (.ico), Graphics Interchange Format (.gif ), JPEG (.jpg), run-length encoded (.rle), or Windows metafile (.wmf ).
Example
The following example loads an image into an Outlook contact form:
Function Item_Open( ) Dim oPic Set oPic = LoadPicture("C:\windows\" & Item.FullName & ".bmp") Set Item.GetInspector.ModifiedFormPages("General").imgContact.Picture = _ oPic End Function
Programming Tips and Gotchas
The StdPicture object is defined by the OLE Automation library STDOLE2.TLB. It supports the members shown in the following table:
Name | Type | Description |
Handle | Property | Returns a handle to the image. |
Height | Property | Indicates the height of the image in HiMetric units. |
hPal | Property | Returns a handle to the Picture object’s palette. |
Render | Method | Draws all or part of the image to a destination object. |
Type | Property | Returns the Picture object’s graphics format. Possible values are 0 (none), 1 (bitmap), 2 (metafile), 3 (icon), and 4 (enhanced metafile). |
Width | Property | Indicates the width of the image in HiMetric ... |
Get VBScript in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.