WinCC VBScript PictureName Error: GraCS Directory Solution

David Krause13 min read
SiemensTroubleshootingWinCC
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

WinCC VBScript PictureName Error: GraCS Directory Solution

Problem Overview

When loading bitmap or JPEG images into a WinCC HMI screen via VBScript, engineers frequently encounter the runtime error Microsoft VBScript runtime error: Out of memory: 'ScreenItem.PictureName'. The error is generated by the WinCC runtime VBScript host (the WinCC ScriptHost engine) when the PictureName property of a graphic object is set to a path that the runtime cannot resolve against the project's runtime picture pool. The symptom presents itself identically on WinCC 2008 SP2, WinCC 2008 SP3, and the early WinCC V11 (TIA Portal) OCX-based runtime: the script stops at the assignment line, the diagnostic buffer logs error 0x800A0007 (hex) or decimal -2146827865, and no image is rendered.

The original problem statement describes the following failing pattern on WinCC 2008 SP2 with a Microsoft Forms 2.0 Image control inserted as an OCX on the PDL Cajon1:

Dim hmio
Set hmio = HmiRuntime.Screens("Cajon1").ScreenItems("Image_1")
hmio.picture = LoadPicture("C:\Dibujo3.bmp")

The error is raised immediately at the hmio.picture = ... line (or at the equivalent hmio.PictureName = ... line if the engineer switches property names). The Microsoft Forms 2.0 Image control rejects the call because LoadPicture requires an absolute path on the engineering station's local file system, but the WinCC runtime resolves picture references against the GraCS directory of the active project, not against arbitrary absolute Windows paths.

Critical constraint: WinCC runtime graphics are loaded through the picture cache manager. The runtime only enumerates files located inside the project GraCS folder (and subdirectories of GraCS). Absolute paths to C:\, D:\, network shares, or UNC paths are silently refused or trigger the "Out of memory" exception depending on the version.

Root Cause Analysis

Three distinct root causes converge to produce the observed failure. Each must be examined independently to determine which combination applies to a given installation.

Cause 1: Image Is Not in the GraCS Directory

WinCC's graphic system (the GRPCS.dll picture cache) only enumerates picture files (.bmp, .jpg, .jpeg, .emf, .wmf, .png from V6.2 SP1 onward) that are physically present inside the GraCS folder of the running project. The GraCS directory is created automatically by WinCC Explorer at <ProjectPath>\<ProjectName>\GraCS on the engineering station and at the corresponding path on the runtime station. Any LoadPicture call pointing outside this folder is rejected by the runtime script engine.

Cause 2: Wrong Property Name for the Object Type

The Microsoft Forms 2.0 Image control exposes two distinct properties:

  • Picture — expects an IPictureDisp COM object (the return value of VBScript's LoadPicture function). Assigning a string to Picture always fails.
  • Image — used to bind control behavior; not the same as the WinCC graphic property.

The native WinCC Graphic Object (the standard "Graphic Object" you drop from the toolbox onto a PDL) does not expose a Picture property at all. It exposes only PictureName, which is a string property accepting a file name relative to the GraCS directory.

Cause 3: Microsoft Forms 2.0 Image Control Is Not Licensed for Runtime Manipulation

The Forms 2.0 Image control was designed for VBA (Excel, Access, VB6) environments, not for industrial HMI runtimes. In WinCC 2008 SP2, embedding Forms 2.0 controls is possible but the runtime does not propagate LoadPicture-bound IPictureDisp objects cleanly through the HMI runtime. This is the reason the thread ultimately resolved by switching to a WinCC OCX graphic control from the WinCC V11 toolbox.

Environment and Prerequisites

Component Tested Version Notes
WinCC Explorer V7.0 SP2 (2008) Original failure environment
WinCC Runtime V7.0 SP2 32-bit only; uses Microsoft Scripting Engine 5.8
Windows OS Windows XP SP3 / Windows 7 SP1 Both x86 editions supported
Microsoft Forms 2.0 FM20.DLL version 12.0.x Installed with Office or Visual Studio 6
WinCC V11 OCX WinCC V11 (TIA Portal) Recommended replacement path
Image formats BMP, JPG, JPEG, EMF, WMF PNG supported only from V6.2 SP1

Confirm the following before applying any fix:

  1. The WinCC project is loaded in runtime (yellow "RT" indicator in the taskbar).
  2. The user account running the WinCC runtime has read/execute rights on the project directory.
  3. The image file exists physically on disk on the runtime machine, not only on the engineering machine.
  4. The image is not locked by another process (Photoshop, paint program, etc.).
  5. The project has been compiled and activated at least once after the image was added.

Solution 1: Place the Image in the GraCS Directory (Recommended for WinCC 2008)

This is the canonical solution and is the approach the support thread ultimately identified as correct for WinCC 2008 SP2.

Step-by-Step Procedure

  1. Locate the GraCS directory of the project. Default location:
    C:\Program Files\Siemens\WinCC\WinCCProjects\<ProjectName>\GraCS\
  2. Copy Dibujo3.bmp (or any target image) into this folder.
  3. Open the WinCC Graphics Designer and place a standard Graphic Object (not the Forms 2.0 control) onto the target PDL.
  4. Configure the Graphic Object's initial PictureName property to a placeholder file in GraCS, e.g. placeholder.bmp.
  5. Add a VBScript action to a button or event, and use the following code:
' Correct pattern for a native WinCC Graphic Object
Dim oScreen, oItem
Set oScreen = HmiRuntime.Screens("Cajon1")
Set oItem   = oScreen.ScreenItems("GraphicObject_1")

' PictureName is a STRING relative to the GraCS directory
' No path prefix, no drive letter, no leading backslash
oItem.PictureName = "Dibujo3.bmp"

' Optional: trigger a screen refresh
oScreen.Refresh()

If the image must be in a subfolder of GraCS, use a forward slash (VBScript on WinCC runtime accepts both / and \):

oItem.PictureName = "Pictures\States\Dibujo3.bmp"

Solution 2: Correct Microsoft Forms 2.0 Image Property Syntax

If the project must keep the Forms 2.0 Image control (e.g., for animation features not available on the standard Graphic Object), use the Forms 2.0 native property model rather than the WinCC pattern:

' Forms 2.0 Image control — uses .Picture, not .PictureName
Dim oItem
Set oItem = HmiRuntime.Screens("Cajon1").ScreenItems("Image_1")

' LoadPicture returns an IPictureDisp — must be assigned to .Picture
oItem.Picture = LoadPicture("C:\Program Files\Siemens\WinCC\WinCCProjects\MyProject\GraCS\Dibujo3.bmp")

' Cleanup: release COM object when finished (best practice in loops)
' Set oItem.Picture = Nothing
Important: The Forms 2.0 control can load a picture from a fully qualified path, but the picture file must still be located on the runtime machine at the exact path specified. Network paths and relative paths fail. The original code in the support thread failed because C:\Dibujo3.bmp did not exist at that exact location, and the runtime could not enumerate the path against its picture cache.

Solution 3: Switch to the WinCC V11 OCX Graphic Control

The support thread's final resolution was to abandon both Forms 2.0 and the legacy Graphic Object in favor of the WinCC V11 (TIA Portal) OCX control. This is the recommended path for new development and for migration projects.

Procedure

  1. Open the project in TIA Portal with WinCC V11 or later installed.
  2. From the toolbox, drag the WinCC Graphic Object (TIA) onto the screen.
  3. Configure the picture source path in the configuration dialog (accepts both GraCS-relative and absolute paths).
  4. Add a VBScript handler on a button click event:
' TIA Portal V11+ WinCC OCX pattern
Dim oScreen, oItem
Set oScreen = HmiRuntime.Screens("Cajon1")
Set oItem   = oScreen.ScreenItems("WinCCGraphicObject_1")

' TIA Portal OCX accepts full paths when configured to do so
oItem.PictureName = "Dibujo3.bmp"           ' relative to GraCS
oItem.PictureName = ".\GraCS\Dibujo3.bmp"    ' explicit relative
oItem.PictureName = GetProjectPath() & "\GraCS\Dibujo3.bmp"  ' absolute via helper

The TIA Portal OCX exposes both a configuration-time picture selection dialog and a runtime PictureName property, making it strictly more flexible than the legacy Forms 2.0 control.

Error Code Reference

Error String Hex Code Decimal Meaning Fix
Out of memory: 'ScreenItem.PictureName' 0x800A0007 -2146827865 Property assignment failed — picture cache cannot resolve path Move image into GraCS; use correct property
Object doesn't support this property or method: 'Picture' 0x800A01B6 -2146827850 Property does not exist on this object type Use PictureName on WinCC Graphic Objects
Type mismatch: 'LoadPicture' 0x800A000D -2146828275 Argument is not a valid path string Verify path exists, no special characters
Permission denied: 'LoadPicture' 0x800A0046 -2146828218 File locked or no read permission Close image in editor, check ACLs
File not found 0x800A0035 -2146827251 Path does not resolve to a file Confirm image is in GraCS and on runtime machine

Path Resolution Rules in WinCC Runtime

The runtime picture cache follows a strict set of resolution rules. Understanding these rules eliminates the majority of "works in Graphics Designer, fails in runtime" issues.

  1. GraCS-relative resolution: When PictureName contains no drive letter and no leading separator, the runtime prepends the project GraCS path. Example: "States\Run.bmp" resolves to <Project>\GraCS\States\Run.bmp.
  2. Absolute path fallback: When PictureName contains a drive letter (e.g., C:\...\image.bmp), WinCC 2008 SP2 attempts the literal path. WinCC V11+ (TIA Portal) honors this only if the picture is also registered in the project picture pool.
  3. UNC paths: \\server\share\image.bmp is generally not supported at runtime. Pictures must be local to the runtime station.
  4. Environment variables: The runtime does not expand %TEMP%, %PROGRAMFILES%, or user variables inside PictureName. Use ExpandEnvironmentStrings in a VBScript helper if needed.
  5. Case sensitivity: Windows file system is case-insensitive, but the runtime picture cache matches names case-sensitively when comparing against the project database. DIbujo3.bmp and dibujo3.bmp are treated as distinct files.
  6. File extension: The extension is mandatory. "Dibujo3" without .bmp returns "file not found".

Helper Function: GetProjectPath

For code that must build absolute paths programmatically, deploy the following helper as a project-wide function in WinCC:

Function GetProjectPath()
    ' Returns the project directory without trailing backslash
    Dim sPath
    sPath = HmiRuntime.ProjectPath
    If Right(sPath, 1) = "\" Then sPath = Left(sPath, Len(sPath) - 1)
    GetProjectPath = sPath
End Function

Function GetGraCSPath()
    GetGraCSPath = GetProjectPath() & "\GraCS"
End Function

' Usage
oItem.PictureName = GetGraCSPath() & "\Dibujo3.bmp"

Property Mapping Reference: WinCC Object Types

Object Type Picture Property Accepts String? Accepts IPictureDisp? GraCS Required?
WinCC Graphic Object (legacy) PictureName Yes No Yes
Microsoft Forms 2.0 Image Picture No Yes (via LoadPicture) No (any path)
WinCC V11+ OCX Graphic PictureName Yes No Recommended
WinCC SmartClient SVG SVGPath Yes No Yes (from V7.0)
WPF-based Graphic View (V14+) Source Yes (URI) No Yes

Verification Procedure

After applying any of the solutions above, execute the following verification sequence on the runtime machine:

  1. File-system check: Confirm Dibujo3.bmp is present in the GraCS directory of the running project. Use Windows Explorer or dir "C:\Program Files\Siemens\WinCC\WinCCProjects\<Project>\GraCS\Dibujo3.bmp".
  2. Project activation: In WinCC Explorer, deactivate and re-activate the runtime. The picture cache is re-enumerated only at activation time. A hot reload via rt-activate is not sufficient for picture cache changes.
  3. Runtime diagnostic buffer: Open the WinCC Alarm Logging or the GSC diagnostic window (Alt+Print, or HmiRuntime.Trace in a script). Confirm no entry for error 0x800A0007 is logged after the script runs.
  4. Visual confirmation: Trigger the button event. The image should swap on the screen within one or two screen refresh cycles (typically 250–500 ms).
  5. Property inspection: In a script, read the property back immediately after assignment:
    Debug.WriteLine "After assign: " & oItem.PictureName
    The output should match the assigned value exactly. A blank value indicates the assignment was rejected by the picture cache.
  6. Cross-station test: If the project is deployed to a separate runtime PC, copy the image file to the remote GraCS directory. Pictures are not automatically transferred by project replication.

Common Pitfalls and Field Notes

Pitfall 1: Image In Engineering Folder But Not Runtime Folder

On dual-machine setups (engineering station + runtime server), the image must be present on the runtime server. Pushing the WinCC project via Project Duplicator copies the project tree including GraCS, but custom subfolders created directly inside GraCS via Windows Explorer may not be picked up by the project duplicate process. Verify the picture list in WinCC Explorer: Project > Picture. Missing pictures indicate a sync problem.

Pitfall 2: Picture Cache Corruption After Editing

If an image is overwritten externally (e.g., a paint program saves over Dibujo3.bmp while the runtime is active), the picture cache holds a stale handle. The fix is to either (a) use a different filename and assign the new name, or (b) deactivate and reactivate the runtime to force cache reload.

Pitfall 3: BMP Format Limitations

WinCC 2008 SP2 BMP support is limited to 24-bit and 32-bit uncompressed. 1-bit, 4-bit, 8-bit RLE-compressed, and OS/2-format BMPs are not rendered and trigger picture load errors that surface as the same "Out of memory" message. Convert to 24-bit BMP using MS Paint, or use JPEG which has no such constraint.

Pitfall 4: Forms 2.0 COM Cleanup

When loading multiple images in a loop, the Forms 2.0 LoadPicture function leaks GDI handles if the previous picture is not explicitly released. Insert oItem.Picture = Nothing before each reassignment in long-running loops.

Pitfall 5: WebNavigator / WinCC Runtime Advanced

When the project is published via WebNavigator, the image must be deployed to the WebNavigator server's GraCS directory and the runtime GraCS directory. The web client downloads pictures on demand from the WebNavigator server, not the runtime. Mismatched paths produce a broken image icon in the browser, not the "Out of memory" error in VBScript.

Best Practices for Production Projects

  1. Use a dedicated subfolder inside GraCS for application pictures: GraCS\AppPictures\. Avoid placing pictures at the GraCS root to prevent name collisions with system pictures (e.g., OK.bmp, Cancel.bmp).
  2. Use lowercase filenames and 8.3-compatible names for projects that may be exported to older WinCC versions.
  3. Prefer JPEG or PNG over BMP for storage efficiency. A 1024×768 24-bit BMP is ~2.4 MB; the equivalent JPEG is typically under 200 KB at 90% quality.
  4. Centralize picture management with a project-wide include file: PictureLibrary.inc exposing string constants for every picture name.
  5. For animated or frequently changing picture lists, generate the picture set at activation time from a startup script rather than embedding them statically.
  6. Use the Application.Pictures collection (where available) to enumerate and validate pictures at startup, logging any missing files to the diagnostic buffer.

Migration Path: WinCC 2008 SP2 → TIA Portal V11+

Projects migrated from WinCC 2008 SP2 to TIA Portal V11 or later benefit from a more permissive picture resolution system, but the GraCS convention is preserved. During migration:

  • All pictures in the source GraCS directory are copied into the TIA Portal project's \IM\ folder by the TIA migration tool.
  • References in the migrated VBScript code (PictureName = "Dibujo3.bmp") continue to work without modification.
  • Forms 2.0 OCX controls are not migrated automatically; replace them with the new TIA "Graphic IO Field" or "Graphic View" controls.
  • Any absolute path references (e.g., C:\MyPics\foo.bmp) must be manually rewritten to GraCS-relative paths.

Diagnostic Logging Recipe

Add the following snippet at the top of any picture-loading script to capture diagnostic context on failure:

Sub LoadImageSafe(sFileName)
    Dim sFullPath, oItem, oScreen
    Set oScreen = HmiRuntime.ActiveScreen
    Set oItem   = oScreen.ScreenItems("GraphicObject_1")
    sFullPath   = GetGraCSPath() & "\" & sFileName

    On Error Resume Next
    oItem.PictureName = sFileName
    If Err.Number <> 0 Then
        ' Log to WinCC diagnostic buffer
        HMIRuntime.Trace "Picture load failed: " & sFullPath & " | Err=" & Hex(Err.Number) & vbCrLf
        Err.Clear
    End If
    On Error Goto 0
End Sub
Field note: The HmiRuntime.Trace output is visible in the WinCC Diagnostic Window (Start > Programs > Siemens Automation > WinCC > Tools > WinCC Diagnostic Window). Always review this output during commissioning when a picture change appears to fail silently.

FAQ

Why does WinCC throw 'Out of memory' when the image file is clearly present on the C: drive?

The error is misleading: the runtime is not reporting actual memory exhaustion. It indicates the WinCC picture cache cannot resolve the path against the GraCS directory. Move the file into <Project>\GraCS\ and reference it by filename only (no drive letter), and the error will disappear.

Should I use the Microsoft Forms 2.0 Image control or the native WinCC Graphic Object?

Use the native WinCC Graphic Object for all new development. It exposes a string-based PictureName property, integrates with the picture cache, supports configuration-time preview in Graphics Designer, and avoids the COM cleanup and path-resolution pitfalls of Forms 2.0. Reserve Forms 2.0 for legacy migrations where the property interface is already deeply embedded in existing scripts.

Does the same error occur in WinCC V11 / TIA Portal?

The error string and error code are the same in TIA Portal WinCC V11 through V18, but the picture resolution system is more permissive: the OCX graphic control accepts both GraCS-relative and absolute paths when the picture is also registered in the project picture pool. The recommended path remains GraCS-relative for portability across multi-station deployments.

Can I load a picture from a network share at runtime?

Not reliably. WinCC runtime enumerates pictures from the local GraCS directory only. If you must display a network-resident picture, copy it to a local cache folder at startup using a VBScript FileSystemObject operation, then reference the local copy via PictureName.

What is the maximum BMP resolution supported?

WinCC 2008 SP2 supports BMPs up to 8192×8192 pixels in 24-bit or 32-bit uncompressed format. In practice, keep runtime pictures under 2000×2000 to preserve picture cache memory and screen refresh performance. Use JPEG for photographic content and BMP only for line art and UI icons.

Back to blog