Siemens Industry Online Support
Siemens AG
Entry type: Application example Entry ID: 15162450, Entry date: 11/12/2013

Automatic generation of an S7 data block with STEP 7 V5.x from an MS Excel 2003 table

  • Entry
  • Associated product(s)
Task Values from a Microsoft Excel 2003 table shout be transfer into a data block in STEP 7 (V5.x from V5.1). ...

Values from a Microsoft Excel 2003 table shout be transfer into a data block in STEP 7 (V5.x from V5.1).

The Excel file attached contains macros that you can use to create a source file for an S7 data block from an Excel workbook. 
When filling in the Excel workbook, you have to keep to certain obligatory fields and formats. The source for the data block is then generated automatically by the macro.
If you also have STEP 7 V5.x installed on the same computer as MS Excel is installed, you have the further option of saving and compiling the DB source generated directly in the STEP 7 project storage in order to generate the executable S7 data block.

The following functions are available to you as Excel macros:

  • New DB
  • Read DB from file
  • Check DB
  • Save DB as STL file
  • Compile DB

Detailed description
The import/export interfaces are available for data transfer between STEP 7 V5.x and other tools like MS Excel, for example. 
Blocks are imported/exported via the source file. This ensures that no inconsistent data is generated by an import in the STEP 7 data storage. 


In order to be able to generate a data block from source, it is necessary that the source has the right structure. Please also refer here to Entry ID 837001.

Using the macro "Save DB as AWL file" in the Excel file attached you can generate a source file for an S7 data block from the Excel workbook. This source file is saved in the Windows file system as ".awl" and can be imported as described above into STEP 7 V5.x as external source. 
Requirement: you fill in the marked fields of the Excel workbook and insert the data between the statements "STRUCT" and "END_STRUCT".
If the lines provided are not enough, you can add more as required.

If you have STEP 7 V5 installed on the same computer, you can use the macro "Compile DB" to import the source file directly to STEP 7 V5 and generate the data block.
The Excel macros use the command interface of STEP 7 V5 available with STEP 7 V5.1 and higher. Via this interface you can execute functions in STEP 7 V5 from any Visual Basic applications. 
The complete description of the STEP 7 V5.x command interface is available on the STEP 7  CD in the "Manuals" directory.


Content of the Download Download
The download "CreateS7DB.zip" contains an Excel file with macros for generating an S7 data block source and for importing the source into a STEP 7 V5.x project and for compiling to an S7 data block. Create_S7DB_V13.zip ( 376 KB )

Executability and test environment
The Excel file with the macro is compatible with MS-Excel 2003. For automatic generation of data blocks you need at least STEP 7 version V5.1.


Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit