How to write snips with a 3rd party application with the DataSnipper formula

The DataSnipper formula below can be used to automatically import documents into worksheets and create snips

How to automatically write snips with DataSnipper?

When using DataSnipper v4.0 and above, any workbook that is opened with a name that ends in (ds) will be parsed (e.g myworkbook(ds).xlsx). Each such workbook can contain one or more cells with DataSnipper tags, which indicate to DataSnipper that a Snip needs to be created at that location. There are two types of DataSnipper tags:

  • Search Tags
  • Coordinate Tags

Each cell that contains one of these types of tags will be parsed whenever the workbook is opened by someone within your company who has DataSnipper installed. Any documents that do not have text will automatically have their Text Recognized (if your organization uses Text Recognition), after which the Snips will automatically be created.

After this process, the Excel Workbook will behave just like any regular Workbook with DataSnipper files included.

Automatically drawn snips are only available in DataSnipper version 4.0.0 and up

Snip from Search

Search tags can be used to Snip every occurrence of a given search query on a page.

As every occurrence of the search query will be Snipped, it's often wise to make your query as specific as possible.

Search tags have the following syntax:

DS_SEARCH[filename|pageNumber|query]
Parameter Description
filename Absolute or Relative filepath, including extension
pageNumber Number of the page on which to search for the query
query The search term to look for. This can be a number, date, word or even a sentence.

For example, If we want to search for all occurrences of the word "DataSnipper" on the second page of a file called "invoice.pdf" the Tag would look as follows:

DS_SEARCH[invoice.pdf|2|DataSnipper]

Snip from Coordinates

Coordinate tags can be used to make a Snip based on its coordinates on the page.

Coordinate tags have the following syntax:

DS_COORDS[filename|pageNumber|x1|y1|x2|y2]
 
Parameter Description
filename Absolute or Relative path to the file, including extension
pageNumber Number of the page on which to search for the query
x1 X coordinate of the top-left corner of the snip, in pixels
y1 Y coordinate of the top-left corner of the snip, in pixels
x2 X coordinate of the bottom right corner of the snip, in pixels
y2 Y coordinate of the bottom right corner of the snip, in pixels

Coordinates can be either supplied as whole numbers (e.g 5) or as decimal numbers with a dot as a decimal separator (e.g 3.5)

 

For example, assume we want to snip the publishing Date on the 2021 Formula One Sporting Regulations. In order to get the right numbers for x1, y1, x2, and y2 we will first need to determine the distance from the top left corner of both the top-left and bottom-right corners of the snip. 

Combining the coordinates with the name of the pdf and the page number gives us the following query:

DS_SEARCH[2021_formula_1_sporting_regulations.pdf|1|302|81|360|90]

How do I ensure that DS formulae can find the right file?

In our examples, we used just the filename of the document to refer to the document. This works if the .pdf file is located in the same directory as the Excel workbook. But if the file is not, we will need to provide a path to the file. There are two ways of doing this:

  1. Relative Paths
  2. Absolute Paths

Relative Paths

A relative path gives a path from whichever folder you have stored the excel workbook in to the file, for example:

PDFS\document.pdf

Therefore, if the excel workbook is located in the following folder:

C:\Users\MaxVerstappen\Documents\DataSnipper

This will result in the file being searched for by the DS formula in the following location:

C:\Users\MaxVerstappen\Documents\DataSnipper\PDFS\document.pdf

You can put "..\" (without quotation marks) in a relative path to allow the DS formula to search one directory higher.

Absolute Paths

An absolute path is a complete path to a file, for example:

C:\Users\MaxVerstappen\Documents\DataSnipper\document.pdf

When to use which Path?

We recommend using Relative Paths for most use cases as it causes fewer issues when sharing workbooks & pdf, as long as the location of the PDFs relative to the workbook stays the same.

In order to ensure that a user can always import the right PDF files, we recommend creating a .zip archive containing both the documents and the Excel workbook when sharing workbooks containing DS formula tags while using relative paths.

Absolute paths work well when the documents are stored on a Shared Network Drive. If your company uses a Shared Network Drive you can refer to the documents by their absolute path. This will allow you to only share the Excel workbook within your company without having to bundle the .PDF files.

When using Integrations with .pdf files on a Shared Network Drive, please ensure that all users have the drive mounted as the same Drive Letter. (e.g the Shared Network Drive is mounted as N: for everyone)