O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 of picturename 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required