Help: how to use your own image on the ribbon button

Use Custom Images

Add Custom Images to the application

To create a button on the Ribbon, you need to assign image to it. You can create interface which has only Labels, Command Buttons, Comboboxes and Separators. But it will not look good. In order to create perfect modern application you need to use your own images in the User Interface.

Buttons on the Ribbon

xlCompiler has 2 methods to add images to the application. We'll start from the first one, which is recommended by Spreadsheet Tools.

Add custom images to the project

Open your xlCompiler project and switch to the Images tab

Custom Images in the Project

Images added to the xlCompiler project are embedded into compiled file as resources. You can assign Name to the every image and refer to the image by this name in the VBA Code.

How to add file to the Image Tab

First method - use Right Click Menu:

Custom Images RCM

Add Image command selects Image on disk and ads it to the project.

Second method - drag'n'drop. Select files you need in the Windows Explorer and drag them to the Image tab. xlCompiler add all of them to the project.

As an alternative you can add images directly to the compiled workbook using VBA macro:

#If XLC Then
	With Application.Icons
		.Add "Calendar", "*Path to file on disk*\calendar.ico"
	End With
#End If

Method Add of the Application.Icons collection adds new icon to the application.

It has following arguments:

Name - name of the image

File - path to the image file on disk

Why we don't recommend this method?

When you install compiled application on the customer's PC, you need to install image files, and know path to the installed file. This is not a robust solution.

This method works, but we suggest to add images to the project file.

Which images should I use?

This is important question. xlCompiler uses 16x16 images for small buttons and 32x32 images to the large buttons. So your image should have one of these sizes.