PasteGraphic is a tool that enable users to either export or import charts and tables from Excel into Word or PowerPoint as a graphic or an object (chart/table). In this way, we can both select a chart or table in Excel and directly export it to either Word or PowerPoint, or import the selected chart or table in Word or PowerPoint. Our external user guide elaborates an example of usage to both export and import.
The feature copies the selected chart or table, and thus paste it where the cursor is placed in Word or into the selected placeholder in PowerPoint.
Further, PasteGraphics enables to locate the source of the inserted graphic as well as update it according to any changes in the source.
PasteGraphics supports overlays. Read more about overlays and how to implement them in this article or jump to the example of overlays on PasteGraphics here.
Module for exporting is located here:
...\ModuleLibrary\PasteGraphics\01_nocontext_Export
Module for importing is located here:
...\ModuleLibrary\PasteGraphics\02_nocontext_Import
Command for copy/paste
This command will copy the selected chart or table from Excel and paste it into Word or PowerPoint as an object or graphic based on what is defined in the parameters. It will automatically be resized due to the size of whatever it is inserted in.
This is compatible in both Excel, Word and PowerPoint. If used in Excel, the button will export the chart or table, while the button imports the chart or table if used in Word or PowerPoint.
Notice that Word or PowerPoint must be opened to insert the chart or table.
Excel number formatting will be preserved.
<Cmd case="SkabelonDesign.PasteGraphics:Paste"/>
Parameters
bindingInsertionType
This can either be an Object
or an Image
. With this parameter, we can determine whether the selected chart or table in Excel should be pasted as the respective object (chart or table) or as a graphic. When pasting an object the object keeps the size of the placeholder it is pasted into. Pasting an image will keep the width and adjust size according to aspect ratio.
We also support importing/exporting a table as an Excel object. This is handy when a table contains traffic lights. Here, the binding type is called ExcelObject
.
destination
Define whether the selected chart or table should be inserted in Word
or PowerPoint
.
BindingSizingType
This parameter is optional. Use it to define that the size (height and width) of the chart or table from Excel should be kept when being exported to Word or PowerPoint.
It is an enum so the parameter supports both a name or a value which be either KeepSourceSize
or 2
. Both options ensures that the size from Excel will be kept.
CenterInPlaceholders
This parameter is optional. Set to true
to place object in the center of a placeholder. Helpful if insertion to placeholder looks wrong.
keepHeight
This parameter is optional. Set to true
to force the chart to keep the height when inserting in small placeholders. This can be helpful if the y-axis title is cut off, because of the small space.
ForceFontSize
If a table is pasted from Excel into PowerPoint, the font will adjust to fit the placeholder in PowerPoint. Setting this to true
forces the font not to change. Note, this can break slide layouts.
Command for PasteXL
This functionality allows the user to copy and paste any content from any source (providing same number of rows and columns) and when pasted into the destination content (PPT/WORD/EXCEL), it holds all the destination formatting. Used for tables where data is continually updated. The command will carry any number formatting (i.e. currency, thousand separator, etc.) over to the destination content.
<Cmd case="SkabelonDesign.PasteGraphics:PasteXl"/>
Parameters
bindingInsertionType
Must be ExcelValues
.
destination
This can be either PowerPoint
or Word
.
SpacerRowColumnConstantValue
Define the value in millimetres, where rows or columns narrower than this will be considered Spacers and not receive any data.
AllowTableShrinking
True
or false
. Will decide if table should shrink if number of columns/rows in source table does not match number of columns/rows in destination.
Command for source
When a chart/table is inserted into Word or PowerPoint, it can be handy to locate where it comes from. This command enables to see the source.
<Cmd case="SkabelonDesign.PasteGraphics:Source"/>
Command for resize
Command will resize tables or charts in Excel to match the selected placeholder in PowerPoint or page width in Word.<Cmd case="SkabelonDesign.PasteGraphics:ExcelResize" appType="PowerPoint"/>
<Cmd case="SkabelonDesign.PasteGraphics:ExcelResize" appType="Word"/>
Command for update
If changes in the source are made after the chart/table has been inserted into Word or PowerPoint, Office will automatically update the inserted one if it is inserted as an object. Thus, this command allows us to update charts and tables that are inserted as images.
<Cmd case="SkabelonDesign.PasteGraphics:Update"/>
Parameters
legacyPasting
Will paste chart/table/shape into selected or first placeholder. If you reset the slide, the placeholder will not appear again - Meaning true
will insert the element into the placeholder, while false
will replace the placeholder.
UpdateValues
Will update values if a table is linked from Excel in Word or PowerPoint. If the parameter is false
, the entire table will update, while true
will only update the values in the cells.
Link cell to ContentControl
It is possible to link the values of a cell in Excel to a ContentControl in Word. If values in the Excel sheet changes, the ContentControl(s) can be updated by a single click. If more cells are selected, the user should use existing pasteXL functionality.
<Cmd case="SkabelonDesign.PasteGraphics:Paste" bindingInsertionType="Object"
destination="Word"/>
This command will create cell binding only if a single cell is selected. If more - the tool acts like it would be a table.
Additionally, the following parameters can be added to the above command:
removeAllSymbols
: if set to true
it removes all non-digit and non-word characters that are at the start of the cell range. If omitted, it is set automatically to false
.
removeSymbols
: In this parameter, a selection of symbols that should be removed from the start of the cell range can be defined. The symbols are separated from each other with a semicolon (;).
linkToActiveWorkbook
: if set to true
it links the cell or table to the active workbook. That means that when updating, it updates the link from the currently active workbook rather than a workbook that is connected to the file path. If omitted, it is set automatically to false
.
showWrapTextWarning
: if set to true
it enables a warning pop-up whenever the cell or the table contains wrapped text.
Example
<Button label="Link data as a table active" icon="Export">
<Cmd case="SkabelonDesign.PasteGraphics:Paste"
bindingInsertionType="Object"
destination="Word"
showWrapTextWarning="false"
removeAllSymbols="false"
removeSymbols="*; ;-"
linkToActiveWorkbook="true"/>
</Button>
Update selected binding
<Cmd case="SkabelonDesign.PasteGraphics:Update"/>
Update all CC bindings
<Cmd case="SkabelonDesign.PasteGraphics:UpdateAll"/>
Links Pane
It is possible to have a button in the ribbon that triggers a pane that features an overview of all the linked elements that are included in the document. This pane is available only for Word, and can be configured into the ribbon using the command below:
<Cmd case="SkabelonDesign.PasteGraphics:links"/>
The pane that appears holds a set of buttons for each linked element, and is presented below:
On the top of the pane, the Refresh (1) and Update All (2) buttons can be found. The former refreshes the pane, in cases where an element has been added or deleted, while the latter updates all of the elements in the document. Furthermore, each element can be controlled individually by 4 additional buttons. The Select (3) button, selects the element in the document, Source (4) displays information about the source document, such as the name of the spreadsheet or the range of cells its information is located, Update (5) updates the element, and Replace (6) replaces the element.
Overlays on PasteGraphics
As an example, the command for source and update can be used as overlay buttons. In this way, they will appear when the inserted graphic is selected in Word or PowerPoint. The video below illustrates 1) how the selected chart can be imported as an object where the source is found, and 2) how the selected chart can be exported as a graphic that can be updated due to changes made in the source.
Comments
0 comments
Article is closed for comments.