Script Help
This is an Excel Add-In written in Microsoft Visual Studio Community 2017 C#/VB.NET and VBA. This is used for bulk data loads into SQL Server, Oracle, Documentum, Markup and Markdown Languages. The functionality within the ribbon allows a quick way of preparing a bulk data load. Otherwise, the requests can be both time-consuming and error prone. This has now been tested on Windows (7, 8.1, 10) & Excel (2010, 2013, 2016).
Table of Contents
Install
Instructions for installation of VBA and VSTO versions.
VBA
How to install the VBA version
- Download the VBA Add-In file
.
- Copy the file to the XLSTART folder on your computer.
%AppData%\Microsoft\Excel\XLSTART\
- Close all open instances of Excel and then launch Excel. The new ribbon should appear.
VSTO
How to install the VSTO version
Dependencies
Software | Dependency | Project |
---|---|---|
Microsoft Visual Studio Community 2017 | Solution | VSTO |
Microsoft Office Developer Tools | Solution | VSTO |
Microsoft Excel 2010 (or later) | Project | VBA, VSTO |
Visual Basic for Applications | Code | VBA |
Extensible Markup Language (XML) | Ribbon | VBA, VSTO |
Microsoft SQL Server CE 3.5 | Database | VSTO |
SQL Server Compact Toolbox | Database | VSTO |
Log4Net | Error Logging | VSTO |
ScreenToGif | Read Me | VBA, VSTO |
Snagit | Read Me | VBA, VSTO |
Badges (Library, Custom, Star/Fork) | Read Me | VBA, VSTO |
Glossary of Terms
Term | Meaning |
---|---|
COM | Component Object Model (COM) is a binary-interface standard for software components introduced by Microsoft in 1993. It is used to enable inter-process communication and dynamic object creation in a large range of programming languages. COM is the basis for several other Microsoft technologies and frameworks, including OLE, OLE Automation, ActiveX, COM+, DCOM, the Windows shell, DirectX, UMDF and Windows Runtime. |
DQL | DQL is used to query Documentum which is a content management system used to create, manage, deliver, and archive all types of content from text documents and spreadsheets to digital images, HTML, and XML components. DQL uses syntax that is a superset of ANSI-standard SQL (Structured Query Language) DQL statements operate on objects and sometimes on tables/rows but SQL statements operate only on tables/rows |
HTML | Hypertext Markup Language is the standard markup language for creating web pages and web applications |
PL/SQL | PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural extension for SQL and the Oracle relational database |
T-SQL | Transact-SQL (T-SQL) is Microsoft's and Sybase's proprietary extension to SQL. SQL, the acronym for Structured Query Language |
UNION | The SQL UNION operator combines the result of two or more SELECT statements. |
VBA | Visual Basic for Applications (VBA) is an implementation of Microsoft's event-driven programming language Visual Basic 6 and uses the Visual Basic Runtime Library. However, VBA code normally can only run within a host application, rather than as a standalone program. VBA can, however, control one application from another using OLE Automation. VBA can use, but not create, ActiveX/COM DLLs, and later versions add support for class modules. |
VSTO | Visual Studio Tools for Office (VSTO) is a set of development tools available in the form of a Visual Studio add-in (project templates) and a runtime that allows Microsoft Office 2003 and later versions of Office applications to host the .NET Framework Common Language Runtime (CLR) to expose their functionality via .NET. |
XML | Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.The design goals of XML emphasize simplicity, generality, and usability across the Internet. It is a textual data format with strong support via Unicode for different human languages. Although the design of XML focuses on documents, the language is widely used for the representation of arbitrary data structures such as those used in web services. |
Functionality
This Excel ribbon is inserted after the “Home” tab when Excel opens. Listed below is the detailed functionality of this application and its components.
Clipboard (Group)
Paste (Menu)
- Paste the contents of the clipboard
Copy Visible Cells (Button)
- Copies only the visible cells from a selection
Format Data Table (Group)
These buttons have the following constraints:
- Only runs on visible columns. Column hiding can be used to control which columns are included in the script formula.
- Attempt to automatically determine data type of column (text, numeric, date) in order to apply correct quoting and formatting.
- For numeric columns if a specific number format has been applied to the entire column then this will be used when formatting the data. This can be used to control the specific data load format of a numeric column if needed.
Format as Table (Button)
- Quickly format a range of cells and convert it to a Table by choosing a Table Style.
Freeze Panes (Button)
- Keep a portion of the sheet visible while the rest of the sheet scrolls
Remove Duplicates (Button)
- Delete duplicate rows from a sheet
Script Actions (Group)
Clean Data (Button)
- This feature runs through all the data in the table and removes unprintable characters and trims leading and trailing spaces.
- The number of cells cleaned is shown in a message box and cleaned cells are highlighted.
- Currently, there must be at least 2 rows in the table
Convert to Null (Button)
- Replaces the zero string values in a named range with “NULL” text value.
Format Date Columns (Button)
- When data is cut and pasted from SSMS into Excel, for whatever reason, Excel chooses to format the dates with the (useless) format "mm:ss.0". This seems to be impossible to configure.
- This feature applies the format "dd-mmm-yyyy" to all date columns it detects in the active table. If there are zero strings in the column instead of “NULL”s, then the column is treated as a string.
Clear Interior Color (Button)
- Clears the interior color of cells in a named range or data table.
Separate Values (Button)
- Separate values into new rows from the selected column by a delimited string value setting
Add Script Column (Menu Buttons)
T-SQL (Transact-Structured Query Language)
- T-SQL Create Table - This menu item will format the script column to drop/create the table then insert the values
- T-SQL Insert Values – This menu item will format the script column to use individual insert statements
- T-SQL Merge Values – This menu item will format the script column to use a merge statement with a select values
- T-SQL Select Values – This menu item will format the script column to be used in insert statements
- T-SQL Select Union – This menu item will format the script column to be used in an update statement
- T-SQL Update Values – This menu item will format the script column to use individual update statements
PL/SQL (Procedural Language/Structured Query Language)
- PL/SQL Create Table - This menu item will format the script column to drop/create the table then insert the values
- PL/SQL Insert Values – This menu item will format the script column to use individual insert statements
- PL/SQL Merge Values - This menu item will format the script column to use a merge statement with a select values
- PL/SQL Select Values - This menu item will format the script column to be used in insert statements
- PL/SQL Select Union – This menu item will format the script column to be used in an update statement
- PL/SQL Update Values – This menu item will format the script column to use individual update statements
DQL (Documentum Query Language)
- DQL Append – This menu item will format the script column to be used in an append statement for Documentum (this is used for repeating values)
- DQL Append/Locked – This menu item will format the script column to be used in an append statement for Documentum (this is used for repeating values) and unlocks and then locks the record.
- The table must contain a column header with 'WHERE'.
- Add “WHERE” before the column name in the header you want to use as criteria.
- DQL Create – This menu item will format the script column to be used in an create statement for Documentum
- DQL Truncate/Append – This menu item will format the script column to be used in an truncate and then append statement for Documentum (this is used for repeating values).
- The table must contain a column header with 'WHERE'.
- Add “WHERE” before the column name in the header you want to use as criteria.
- DQL Update – This menu item will format the script column to be used in an update statement for Documentum
- DQL Update/Locked – This menu item will format the script column to be used in an update statement for Documentum and unlocks and then locks the record.
- The table must contain a column header with 'WHERE'.
- Add “WHERE” before the column name in the header you want to use as criteria.
- GitHub table - creates a table format for GitHub Read Me documentation
- HTML Table - creates a HTML table structure
- XML Values - creates XML structure
Script Variables (Group)
Table Alias (Dropdown)
- Changes the prefix to the header and footer line script column
- These values can be updated using the build button “…” to the right of the dropdown
Date Find Format (Dropdown)
- This is the format the script looks for to finds dates
- It defaults to ‘mm:ss.0’, and can be changed by the dropdown value or free text
- These values can be updated using the build button “…” to the right of the “Date Format” dropdown
Date Replace Format (Dropdown)
- This is the date format the script uses to replace the formatting for date columns.
- It defaults to ‘dd-mmm-yyyy’, and can be changed by the dropdown value or free text
- These values can be updated using the build button “…” to the right of the dropdown
Options (Group)
Add-In Settings (Button)
VSTO
- Types of VSTO Settings
- Application Settings
- These settings can only be changed in the project and need to be redeployed
- They will appear disabled in the form
- User Settings
- These settings can be changed by the end-user
- They will appear enabled in the form
- Application Settings

- VBA Settings
- To add a new setting
ThisWorkbook.CustomDocumentProperties.Add _ Name:="App_ReleaseDate" _ , LinkToContent:=False _ , Type:=msoPropertyTypeDate _ , Value:="31-Jul-2017 1:05pm"
- To update a setting
ThisWorkbook.CustomDocumentProperties.Item("App_ReleaseDate").Value = "31-Jul-2017 1:05pm"
- To delete a setting
ThisWorkbook.CustomDocumentProperties.Item("App_ReleaseDate").Delete
- To add a new setting
Create File List (Button)
- This will create a file listing recursively from a user selected directory
- It will save the .csv and .bat file in the root folder selected.
Help (Group)
How To… (Button)
- Opens a webpage of the read me documentation
Report Issue (Button)
- Opens a page to create a new issue for the product
About (Group)
Add-in Name (Label)
Release Date (Label)
- The release date of the application
Copyright (Label)
- The author’s name