KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Creating a new VP document based on a Sheet
PRODUCT: 4D View Pro | VERSION: 19 R | PLATFORM: Mac & Win
Published On: April 11, 2022

It is possible to create a new 4D View Pro document based on a specific sheet of another 4D View Pro document.

Below is a utility method which will take the View Pro area's name as the first parameter and the desired sheet index number to create a new document only containing the sheet as an object:

// VP_Extract_Sheet

#DECLARE($vpAreaName_t : Text; \
$sheetIdx_l : Integer)\
->$newVP_ob : Object

var $srcVP_ob : Object

$srcVP_ob:=VP Export to object($vpAreaName_t)

$newVP_ob:=OB Copy($srcVP_ob)

$newVP_ob.spreadJS.sheets:=New object( \
VP Get sheet name($vpAreaName_t; $sheetIdx_l); \
$newVP_ob.spreadJS.sheets[VP Get sheet name($vpAreaName_t; $sheetIdx_l)])

$newVP_ob.spreadJS.activeSheetIndex:=0
$newVP_ob.spreadJS.sheetCount:=1


This will allow specific sheets from a VP document or any document imported into a VP area to be extracted as it's own VP document.