Capturing TP700 Project Name in TIA Portal V13 VBScript

David Krause13 min read
HMI ProgrammingSiemensTutorial / How-to
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

Problem Overview

When commissioning a fleet of SIMATIC TP700 Comfort panels running WinCC Comfort V13, the VBScript runtime environment does not expose a built-in function that returns the active project file name. Any VBScript that needs to stamp a unique file name (for example \Storage Card SD\PanelA History.txt) must therefore obtain the panel identifier from a tag rather than from a runtime API call.

The two field-proven workarounds that engineers use on TIA Portal V13 are:

  1. An internal string tag declared with a per-project start value, optionally marked persistent (retentive) so the value survives a power cycle.
  2. The same tag written from the start screen's Loaded event with the project-specific literal, executed automatically at runtime every time the project boots.

For newer TIA Portal versions (V17 and later, including the V20 Unified runtime), a third option is available through the TIA Portal Openness API: the device name can be read from the engineering project, then pushed down to the runtime as a tag value during compile/transfer. This article walks through all three methods with concrete steps, parameter tables, VBScript samples, and a commissioning checklist.

Scope: All references to TIA Portal V13 mean TIA Portal V13 SP1/V13 SP2 with WinCC Comfort V13 SP1/SP2. The TP700 Comfort hardware family (Siemens MLFB 6AV2 124-1GC01-0AX0 7" widescreen variant and 6AV2 124-1JC01-0AX0 7" widescreen variant) is the reference target, but the same logic applies to every TP/KT Comfort and Mobile panel that runs a WinCC Comfort V13 image.

Prerequisites

Item Specification
Engineering software TIA Portal V13 (V13 SP1/V13 SP2 recommended) with WinCC Comfort V13 license
Runtime target SIMATIC TP700 Comfort, MLFB 6AV2 124-1GC01-0AX0 (7" widescreen TFT, 800 x 480, 16 million colors)
Firmware on TP700 V13.0.1.x or newer (compatible with WinCC Comfort V13)
Storage medium Siemens SIMATIC HMI Memory Card (SD) or standard SDHC card up to 32 GB, FAT32
Supply voltage 24 V DC, rated current 0.85 A typical / 1.0 A max per TP700 datasheet
PLC connection (optional, for tag-from-PLC) PROFINET or MPI/PROFIBUS S7 connection with PUT/GET enabled on the S7-300/S7-1200/S7-1500 side
Visual Studio (Method 3) Visual Studio 2019 or 2022 with TIA Portal Openness V17 or V20 references

Why VBScript Cannot Read the Project Name Directly in V13

In WinCC Comfort V13 the HMIRuntime object exposes the Tags, Screens, Alarms, Languages, Devices, ProcessValues, and DataLogs collections, but the object model does not include a member that returns the .hmi13 / .ap13 project name. Functions such as HMIRuntime.BaseScreenName, HMIRuntime.CurrentLanguage, and HMIRuntime.ProjectPath either do not exist or return only internal pointers, not the human-readable project name visible in the project tree.

The only runtime identifiers that WinCC Comfort V13 makes available through standard system tags are limited to entries such as @LocalMachineName, @UserName, @Date, @Time, and a small set of PLC connection diagnostics. The project file name is not exposed through this channel, which forces the engineer to supply the name through the project data instead of reading it from the runtime.

Upgrade path: Starting with TIA Portal V17, WinCC Unified (RT Unified) provides the system tag @HMI_DEVICE_NAME that returns the runtime HMI device name. The corresponding TIA Portal Openness API is documented in the Siemens TIA Portal Openness V20 reference at Accessing device name for HMI Panel (RT Unified). This article also covers that route at the end for engineers planning a migration.

Method 1 — Retentive Internal Tag with Start Value

The simplest approach uses an internal HMI tag whose start value carries the panel identifier. The tag is marked persistent, so the value remains intact after the panel is powered off. VBScript then reads the tag through the SmartTags collection and concatenates it into the file path. This was the first suggestion that emerged in the original support exchange because it requires no VBScript knowledge beyond reading a tag and concatenating a string.

Step-by-step tag configuration

  1. In the TIA Portal project tree, expand HMI Tags and double-click Default tag table.
  2. Add a new tag with the following properties (right-click the table header and select Add new tag):
Property Value
Name HMI_Panelname
Data type WString (or String on legacy 8-bit displays)
Connection Internal tag — leave the connection field empty
Length 80 characters (sufficient for project identifier + path literal)
Start value PanelA (literal matches the project identifier; e.g. PanelB, PanelC, … PanelAD)
Acquisition cycle 1 s
Settings > Persistence Enable

To enable persistence, open the tag's Properties inspector, select the Settings group, and tick Persistent. TIA Portal stores the persistent area in the panel's internal flash and recreates the values on the next boot. The reserved size on TP700 Comfort is 128 KB; the persistent tag consumes 80 + 4 bytes (length field + null terminator), so a fleet of 30 panels can share the configuration safely.

VBScript that reads the tag

' VBS313 - Write data file using persistent panel name
Dim fso, ts, panelName, filePath, sLine

Set fso = CreateObject("Scripting.FileSystemObject")

panelName = SmartTags("HMI_Panelname")              ' reads the retentive WString
If Len(panelName) = 0 Then panelName = "Unknown"

filePath = "\Storage Card SD\" & panelName & " History.txt"

Set ts = fso.OpenTextFile(filePath, 8, True, -1)     ' 8 = ForAppending, True = create, -1 = Unicode
sLine = FormatDateTime(Now, 0) & "," & CStr(SmartTags("DB100_REAL"))
ts.WriteLine sLine
ts.Close

Set ts = Nothing
Set fso = Nothing
Code comment: The -1 constant in OpenTextFile forces Unicode, which matches the TP700 default. Omit -1 only if the destination application explicitly requires ASCII. Switching the open mode to ASCII without re-encoding will corrupt any non-ASCII panel name.

Method 2 — SetTag on Start Screen Loaded Event

Step-by-step start screen event

  1. Open the project tree, expand Screens, and double-click the start screen (typically Screen_1).
  2. In the screen's Properties panel, switch to Events.
  3. Under the Loaded event row, click the empty field, choose SetTag (or SetTagValue) from the system function list.
  4. Configure the function call:
Parameter Value
Tag HMI_Panelname
Value PanelA (per-project literal; e.g. PanelB, PanelC, … PanelAD for the 30-panel fleet)
  1. Repeat the function call for every tag whose start value needs to be project-specific. The Loaded event fires once at the end of the runtime startup, after VBScript globals are initialised.

How to update 30 panels at once

The event definition lives in the start screen, which is part of the compiled project. To roll out the change:

  1. Open each project (or use a master project with project-specific text library entries).
  2. Open the start screen's Loaded event.
  3. Edit the literal value of the SetTag call.
  4. Recompile and download only the HMI runtime, not the PLC build.

For very large fleets, drive the literal from a tag that the PLC writes on first communication, removing the need to touch each panel's project at all:

' On PLC side (S7-1200 / S7-1500)
' DB100.DBB0 = ASCII string of panel name, e.g. 'PanelA\0'
' Use a standard PUT/GET or S7 connection to write into HMI tag HMI_Panelname

Set Acquisition mode for HMI_Panelname to Cyclic in operation with a 2 s cycle. The PLC writes the value once at boot, and the VBScript history function picks it up on the next append.

Method 3 — TIA Portal Openness API for TIA Portal V17+

Engineers migrating from V13 to TIA Portal V17 or later can automate the panel-name assignment through the TIA Portal Openness API. The API exposes the HMI device Name property so a build pipeline can stamp the literal directly into the tag's start value before compiling. The official Siemens reference for the device-name path on RT Unified targets is Accessing device name for HMI Panel (RT Unified).

C# example (Visual Studio 2019/2022 with Openness V20)

using Siemens.Engineering;
using Siemens.Engineering.Hmi;

TiaPortal tia = new TiaPortal(TiaPortalMode.WithUserInterface);
Project project = tia.Projects.Open(new FileInfo(@"C:\Projects\Fleet\PanelA.ap17"));

foreach (HmiTarget hmi in project.GetChildrenOfType<HmiTarget>())
{
    HmiTagTable table = hmi.TagTables.Find("DefaultTagTable");
    HmiTag tag = table.Tags.Find("HMI_Panelname");
    tag.StartValue = hmi.Name;          // write the device name into the start value
}

project.Save();
project.Close();
tia.Dispose();
Runtime-only deployment: Openness writes the value into the engineering project at design time. For Unified RT panels, the runtime side also exposes the device name through system tags, eliminating the need to pre-populate the tag at design time. Refer to the Siemens documentation linked above for the Unified runtime APIs.

Building the History File Path in VBScript

The complete VBScript that combines the tag-based panel name with the SD card path, the timestamp, and the data payload is:

' VBS313-History - Log a single value to the panel-specific history file
Option Explicit

Const ForAppending = 8
Const TristateTrue = -1

Dim fso, ts
Dim panelName, filePath
Dim logLine

Set fso = CreateObject("Scripting.FileSystemObject")

' 1. Pull the panel name from the internal HMI tag
panelName = SmartTags("HMI_Panelname")
If Len(panelName) = 0 Then panelName = "Default"

' 2. Build the path. SD card root on TP700 Comfort is "\Storage Card SD\".
filePath = "\Storage Card SD\" & panelName & " History.txt"

' 3. Compose the CSV line
logLine = FormatDateTime(Now, 0) & ";" _
        & CStr(SmartTags("DB100_REAL")) & ";" _
        & CStr(SmartTags("DB100_INT"))

' 4. Open the file in append mode, create if it does not exist
Set ts = fso.OpenTextFile(filePath, ForAppending, True, TristateTrue)
ts.WriteLine logLine
ts.Close

Set ts = Nothing
Set fso = Nothing

Path constants for TP700 Comfort

Storage Root path in VBScript Notes
SD card \Storage Card SD\ Default for HMI Memory Card, formatted FAT32
USB stick \Storage Card USB\ Front USB port on TP700 Comfort
Network \\server\share\ UNC paths supported if the panel is on a PROFINET network with SMB enabled
Internal flash \Flash\ Reserved for system data, not recommended for user logs

Persistent Storage Configuration on TP700

The TP700 Comfort allocates 128 KB of internal flash to the persistent tag area. Configure it from HMI Device > Properties > Persistent storage:

Parameter Default Recommendation for VBS history
Number of persistent tags 50 Match the number of tags marked persistent; do not over-allocate
Persistent storage size 128 KB Leave at default; each WString tag adds 4 bytes overhead + length
Persistent area Internal flash Accept default; do not redirect to SD card for write-frequency reasons
Update rate On tag change Accept default; updates only when the value changes, not per scan
Wear-level caveat: Internal flash has a finite write endurance. Updating the persistent tag at every VBScript call (every few hundred milliseconds) can burn through the rated cycles within months. Use Method 2 (PLC-driven tag with a 2 s acquisition cycle) or update the persistent tag only on the first run of the shift, then leave the tag untouched.

Verification and Commissioning Procedure

  1. Compile and download. Right-click the HMI station in the project tree and select Compile > Software (rebuild all). Transfer the resulting image via PROFINET or Ethernet using the Download to device button.
  2. Validate with RT simulator. In the TIA Portal V13 menu, choose Online > Simulation > Start with tag simulator. Trigger the VBScript from a button event. Confirm that the file appears under the simulator's virtual SD card path.
  3. Power-cycle test. Disconnect the 24 V supply for at least 30 s, then restore. Verify that HMI_Panelname still contains the expected literal when you read it back from a diagnostic screen.
  4. Inspect the file. Remove the SD card, insert it into a Windows PC, and confirm the file name pattern matches PanelA History.txt, PanelB History.txt, etc.
  5. Compare panel content. Use fc /B *.txt on the SD card to confirm that the bytes appended by PanelA differ from those appended by PanelB. If two panels write to the same file, the SD card root is being mistyped.
  6. Audit with ProSave. Use Siemens ProSave to back up the panel image, then restore on a spare TP700 to verify the persistent tag survives a transfer. ProSave is bundled with TIA Portal under Start > Siemens Automation > ProSave.

Troubleshooting Matrix

Symptom Likely cause Fix
VBS error "Object required: SmartTags(...)" Tag HMI_Panelname missing or data type mismatch Recreate the tag as WString, length 80, in the default tag table
File name is "Default History.txt" on every panel HMI_Panelname tag empty at boot, default branch taken Confirm the start value is filled and the persistence option is enabled, or wire the PLC to write the tag on first cycle
Permission denied when writing to "\Storage Card SD\" SD card write-protected, full, or unformatted Slide the write-protect lock; format the SD card as FAT32 with 32 KB clusters
Tag value resets to start value after every reboot Persistence disabled, or tag is not internal Open tag properties, enable Persistent, confirm connection is internal
VBS appends to a single shared file across all panels Path uses a hard-coded literal instead of the tag Replace the hard-coded string in the VBScript with SmartTags("HMI_Panelname")
PLC writes fail because the HMI tag is read-only on the HMI side Tag direction configured read-only from PLC Switch acquisition mode to Cyclic in operation with the S7 connection
File appears truncated when opened in Excel File is Unicode (BOM) but Excel interprets as ASCII Open with Data > From Text/CSV in Excel and choose UTF-16 LE
VBS fails after firmware update on TP700 Firmware is older than the project image (V13.0.0.x), tag persistence format changed Update TP700 firmware to match the WinCC Comfort V13 build (recommended V13.0.1.5 or newer)
Loaded event never fires Start screen not configured as the initial screen in Project > Runtime settings Open Runtime settings > General > Start screen and select the correct screen
VBS throws "Path not found" on first run after cold boot SD card not yet mounted when VBScript runs Trigger the script from a button event instead of a scheduled task, or add a 2 s delay before opening the file

Migration to TIA Portal V17 / V20 Unified

Teams planning a move off WinCC Comfort V13 should evaluate the following differences:

Feature TIA Portal V13 Comfort TIA Portal V17/V20 Unified
Project name in runtime Not exposed; supply via internal tag Exposed through @HMI_DEVICE_NAME system tag
VBScript support Full VBS replaced with JavaScript-based scripting
Openness device name API Limited Full HmiTarget.Name property, documented at Siemens TIA Portal Openness
Persistent tags Internal flash, 128 KB Tag persistence settings exposed per device, larger area available on Unified panels
File system access VBS FileSystemObject JavaScript FileSystem API
Panel families supported TP/KT Comfort, Mobile Panel 2nd Generation Unified Comfort Panels (MTP/MTP1500/MTP1900/MTP2200) and RT Unified PC

For new projects, prefer the Unified runtime so the panel name is available without an extra tag. For existing V13 fleets, Method 1 or Method 2 keeps the script compatible without recompilation.

FAQ

How do I read the project name from VBScript in TIA Portal V13?

WinCC Comfort V13 does not expose the project name through the HMIRuntime object model. Create an internal WString tag named HMI_Panelname, set its start value to the panel identifier (for example PanelA), enable Persistence in the tag properties, and read it in VBScript with SmartTags("HMI_Panelname").

Can I make an internal HMI tag retentive across power cycles?

Yes. In the HMI tag properties, open the Settings group and tick Persistent. The TP700 Comfort stores up to 128 KB of persistent tags in internal flash and recreates them on the next boot. Do not write the tag in a tight loop; internal flash endurance is finite.

Where does the SD card path begin on the TP700 Comfort?

The root path in VBScript for a Siemens HMI Memory Card is \Storage Card SD\. For a USB stick in the front port use \Storage Card USB\. Network shares are accessible via UNC paths if the panel participates in a PROFINET network with SMB enabled.

How can I set the panel name automatically on boot?

Open the start screen in TIA Portal, go to Properties > Events > Loaded, and add a SetTag function call that writes the literal value into HMI_Panelname. The runtime executes the event once at the end of startup, so the tag is correct before any scheduled VBScript runs.

Is there a system tag that returns the TP700 device name in newer TIA Portal versions?

Yes. WinCC Unified (TIA Portal V17 and later, including V20) exposes @HMI_DEVICE_NAME at runtime, and the engineering side exposes HmiTarget.Name through TIA Portal Openness. The official API reference is at Accessing device name for HMI Panel (RT Unified).

Back to blog