4D Write Pro & Text Boxes: docx Import/Export Options

Introduced with 4D v19 R8, text boxes allow you to insert text, tables, images, formulas, and other elements anywhere into your applications. This feature has been improved in v20 to include the ability to export and import these elements from and to docx documents.

In addition, a new export option has been added that is also valid for other document types!

4D Write Pro & Text Boxes: docx Import/Export Options

Import

Before 4D Write Pro supported text boxes, it was possible to define how text boxes in docx documents should be imported. By default, the content of the text boxes was imported “in line.” They lost their formatting, but at least the content was preserved.

Good news: When importing, text boxes are imported as they are thanks to a new option, wk anchored, which becomes the default option!

// If you set this option, then text boxes will not be imported
$options.anchoredTextAreas:="ignore"

// If you set this option, then text boxes content will be imported as inline text
// This WAS the default value BEFORE 4D v20
$options.anchoredTextAreas:="inline"

// Since 4D v20, there is a new value that allows to import text boxes "as it"
// Note: this IS the NEW default value!
$options.anchoredTextAreas:="anchored" // textboxes are imported as textboxes

WParea2:=WP Import document($file.platformPath; $options)

Export

Like background colors or pictures used in documents, text boxes are considered parts of the background. For some reason, if you need to export your 4D Write Pro documents without their text boxes, just ignore the background when exporting.

This is possible using programming…

$options[wk visible background and anchored elements]:=false
WP EXPORT DOCUMENT(WParea; $path; wk docx; $options)

… or using the interface

CONCLUSION

This feature allows nicer document creation and compatibility to import and export docx documents. Let us know what you think about the 4D Forum!

Roland Lannuzel
• Product Owner & 4D Expert •After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.