show the entry list
WinCC flexible ES -- Product information -- General information
Does WinAC MP 2008 for WinCC flexible 2008 run in Windows 7?
Why can you not select the SIMATIC HMI Panel PC Ex as operator panel in WinCC flexible 2008?
What should you watch out for when installing WinCC flexible 2008 SP3 or WinCC V11 SP2 on an HP notebook?
How do you make printouts on different printers in WinCC flexible PC Runtime?
How can you exchange data between USB storage devices on the Thin Client with an active RDP connection?
What are the functional differences between the different SIMATIC panels?
What options are there for creating a screenshot in WinCC flexible ES, WinCC flexible Runtime or on panels?
What support does Siemens AG offer to make products comply with FDA regulations?
What different CPU technologies are available in the PC sector and what are the advantages offered by SIMATIC PCs with Intel® Core™ 2 Duo processors when using SIMATIC software?
How do you send customer projects to Technical Support?
Why are PDF documents not displayed properly on the MP377?
Which GSD files are there for the Profibus DP operator panels?
Which GSDML files are there for the operator panels for Profinet IO?
WinCC flexible ES -- Creating HMI configurations -- Creating scripts
How do you make printouts on different printers in WinCC flexible PC Runtime?
How are tags archived in WinCC flexible STRING?
How do you access an SQL database in WinCC flexible via a script?
Tips and tricks for creating scripts
How can you implement a wait function (delay) in a script?
How on a PC with WinCC flexible can you use a script to save and read out information in a text file?
How on a Windows-based panel can you use a script to save and read out information in a text file?
How do you start a sound file via a script in the WinCC flexible PC Runtime?
How do you dynamize objects in WinCC flexible via scripts?
Which VBS information and programming aids are there in WinCC flexible?
WinCC flexible ES -- Creating HMI configurations -- Outputting protocols, screens, messages and documents
How do you configure a screen change via the controller in WinCC flexible?
How do you make printouts on different printers in WinCC flexible PC Runtime?
How can you import/export configuration data (discrete and analog alarm messages, tags and connections) from/to a CSV file in WinCC flexible 2008?
How can you have hardware diagnostics data of SIMATIC IPCs displayed in WinCC flexible?
How can you do a report logging, a hard copy or report printing on a printer with Windows-based panel via HyperTerminal?
How is the diagnostic data of the DP diagnostics block FB125 in WinCC flexible visualized?
What settings do you have to make to be able to print on a network printer with a Windows-based panel (except the 170 series)?
How can you switch off the "Sleep" function on Brother printers?
How do you open a WORD document via an operator panel?
How can you use an operator panel to output a variable text input as barcode on a printer?
How do you make printouts on different printers in WinCC flexible PC Runtime?
Part number:

Instructions
In WinCC flexible PC Runtime you cannot explicitly specify printers for printouts. All printouts from the WinCC flexible PC Runtime are always output on the default printer set in Windows.

To have printouts from WinCC flexible PC Runtime output on different printers, the printers concerned must be installed as default printers in Windows. You can do this manually before each printout using the Printer dialog in Windows (Start > Settings > Printers and Faxes > Define as default), but this is inconvenient. Alternatively the default printer can be changed with a VB script while WinCC flexible Runtime is running. You can link this script to a button, for example, which sets a specific printer as default printer in Windows and then starts the printout. The script is structured so that you can use it repeatedly and the printer to be activated is transferred to the script as a parameter.

Procedure
Please proceed as follows to create the script.
 
No. Description
1

Create a new script
Navigate in the project tree to the "Scripts" area and create a new script with "Add Script". The new script is opened automatically in the working area.


Fig. 01

2

Make the basic settings of the script
After the empty script has been opened, you can make the basic settings in the inspector window. Here you specify a unique name for the script, for example "fSet_DefaultPrinter" and select "Function" as type. Create a new parameter, for example "sPrinterName", and add this to the interface of the script using "Add".


Fig. 02

3

Create a new tag
In WinCC flexible you create a new tag of the "Bool" type, for example "RETVAL_fSet_PrinterDefault". This tag later contains the return value of the "fSet_DefaultPrinter" function; if the function is executed without an error, the value is "1", otherwise "0". Configure the tag as below.


Fig. 03

4

Program the script
Now program the script for changing the default printer in Windows. The complete script is given at the end of this entry or as a text file in the download of the FAQ entry.


Fig. 04

5 Buttons for printer change
Configure a separate button in a picture for each of the printers to be used. The figure shows a switch between the two printers "MA11193D" and "Adobe PDF".
The return value "RETVAL" of the "fSet_DefaultPrinter" function is shown in an IO field. Link the "RETVAL_fSet_DefaultPrinter" tag to the IO field.


Fig. 05

6

Determine the printer name in Windows
Proceed as follows to determine the printer name for the script in WinCC flexible.

Open this path in Windows: "Start" > "Settings" > "Printers and Faxes".
There you will find a list of all the printers available and their names. Use a unique (sub)string from a name in the list as the "sPrinterName" parameter of the script. For example "Adobe PDF" and "MA11193D" as in the screenshot shown.


Fig. 06

7

Script call with the buttons
Open the Properties of one of the two buttons and configure a call of the "fSet_DefaultPrinter" script in the function list under "Events > Click".
Assign the call as shown. Provide the return value with the "RETVAL_fSet_DefaultPrinter" tag created in Step 3. Use the printer name as created in Windows as parameter for the printer name "sPrinterName". Repeat this step for each printer and each button you have created in your picture. You can use the same tag each time as return value, because it is always the same script that is executed. However, the printer name must be changed for each separate call.


Fig. 07

Complete VB script
The complete script is in the PDF file below.

WinCC_flexible_RT_changing_printer_Skript_e.pdf ( 9 KB )

Keywords
Output device, Switch, Redirect, Change, Default printer, DefaultPrinter

 Entry ID:49741726   Date:2011-04-27 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Topics
Help
Online Help
Guided Tour