CorelDraw & VBA
Back to the Main Menu
VBA Introduction
Artistic Text
Paragraph Text
Finding & Changing Text
Master Layers
Opening Other Applications
User Interface
Event Programming
Storing User Data
Error Handling
Speeding Up CorelDraw
VBA Security
Guide to CorelDraw VBA

VBA Security

This section is not about how to avoid viruses but instead on how to prevent the Security Warning that the file you are about to open contains macros. This is particularly useful when you give the file to someone else to use.

Those programs such as CorelDraw, Word, Excel and Access that can run VBA code will not by default run that code automatically. By default they warn you of potential danger and give you the option to run the macro.

Open a new CorelDraw document or any existing CorelDraw document and select Tools in the tool bar, then select Options. In the dialog box that opens make sure you expand Workspace on the left hand side. Then select VBA. You will then see the dialog box below in CorelDraw X4.

Select the button Security Options... and you will see the following dialog box.

Make sure that "Medium. You can choose......" is selected. You must be in charge of what macro can run!

CorelDraw 12 and X3 show a dialog box shown below that combines the two dialog boxes shown above into one dialog box that does exactly the same thing.

Now when a CorelDraw file opens with a macro at least it will give you the option to open it with the macro not open the file without the ability to run the macro.

Now select "Enable Macros" to run the macros.

Creating A Self-Signed Digital Certificate

Unless you selected a low security level very time you open your own files containing a macro there will be a warning that the file file may be unsafe. You need to create a trusted Security Certificate. This is particularly important if you have supplied a file containing a macro. They will be pestered each time they open the file that the file may contain viruses. If they disable the macro they will not get the functionality that you have supplied.

To create a digital certificate you must have Microsoft Office and open selfcert.exe
This is located in the following depending on your version of Office and your location of your programs which by default are on the C drive. In Office 2003 it is in Microsoft Office Tools where it is called Digital Certificate for VBA Projects.

Office 97        C:\Program Files\Microsoft Office\Office
Office 2000C:\Program Files\Microsoft Office\Office10
Office 2002C:\Program Files\Microsoft Office\Office10
Office 2003C:\Program Files\Microsoft Office\Office11
Office 2007C:\Program Files\Microsoft Office\Office12
Office 2010C:\Program Files (x86)\Microsoft Office\Office14

Enter your name, company name or any name for your certificate. Spaces in the name are OK. Select OK and the certificate is created. The certificate will expire in about 6 years. You can also create other certificates with the same name but at different times.

Applying Your Digital Certificate To Your Code

Now that you have a digital certificate you can sign your macro projects. In CorelDraw in the VBA IDE select Tools Then Digital Signature and you will get the following dialog box.

If you have previously used a certificate there will be a Certificate name in Sign as rather than [No certificate]. Press the button Choose. You will now see all certificates that you have created.

Select your signature the press OK. The new dialog box will look as follows but with your personalised certificate name.

Now once your CorelDraw file is saved it can be opened on this same computer without any warnings about dangerous macros.

Using Self-Signed Digitally Certified Macros On Other Computers

If you open the file containing the signed macro on another computer there will be a warning that the file contains a signed macro as shown below.

If you select Enable Macros then files signed by, in this case "Corel-VBA" will open but you will continue to always get a warning. Instead get the second computer to always trust signed macros with this certificate. To do this you cannot directly select "Always trust macros from this publisher" as it is grayed out. To un-gray it select "Details" and you will get this next dialog box.

You must now click View Certificate.

Now click Install Certificate and you will see the following.

Select Next.

Leave the selection to automatically select the certificate store and then select Next.

Select Finish.

Select Yes.

This brings you back to the next dialog box.

Click OK to get the next dialog box.

Clicking OK gets us back to where we started.

It seems that we have no where but click Enable Macros and the file will open. Now close CorelDraw and reopen the file and CorelDraw will now recognise that you have a certificate from this publisher.

Now select Always trust macros from this publisher then press Enable Macros. Now all CorelDraw files opened on this computer that are signed with the certificate will open without a warning of potential danger.

In essence what you have to do is view the certificate. Only then you can allow any program that later uses the certificate to open without hindrance.

Note! You cannot modify the VBA code on this computer and retain the certificate as only the computer where the certificate was created can sign VBA code with the certificate.

Moving or Deleting a Digital Certificate

Open Internet Explorer and select Tools then select Internet Options then select the tab Content. In the middle of the dialog box is a button Certificates. Select the button with the mouse.

Your Digital Certificate will be in one of 6 tabs. Note there are two tiny buttons on the right to allow you to see all 6 tabs. The tabs are called;
Other People
Intermediate Certificate Authorities
Trusted Root Certificate Authorities
Trusted Publishers
Untrusted Publishers

Select your Certificate and select Remove to delete the Certificate.

Although it appears you have the option. You cannot effectively export a Self-Signed Digital Certificate as the resultant file will not contain the secret Private Key that is required to use the Certificate elsewhere. If you write code at work and also at home have two Self-Signed Digital Certificates, one at work and another at home. They can have the same name but configure both computers to accept code from either certificate.

Issued 2017_08_31