Steven John Lally
Steven John Lally

Reputation: 142

Communication between VSTO and .XLL

In Visual Studio, I have a solution. In that solution I have 2 projects. One is a VSTO so that we can make a plugin for Excel. The other project is for creating a .xll file so that we can have Custom Functions.

The VSTO helps us create a login system on excel so that they can do certain things.

However, since we only want our users to be able to use our custom functions they have to log in. I think that these 2 projects can't communicate directly so the .xll addin wouldn't know if a user is logged in or not.

Is there anyway for these 2 projects to communicate? Perhaps via a middle-man like a class with static variables?

EDIT:
More information:
Both projects are written in C# code. I was able to do that for the .xll file by using ExcelDNA.

So if there's any way that I can create maybe a C# class that can coordinate or share data between the two projects that would be really great. Since login data isn't the only thing that we want to share.

I'm hoping in the class there would be a static boolean variable holding whether the user is logged in. So the VSTO could set the boolean value and the .xll could get it.

Upvotes: 1

Views: 823

Answers (2)

Govert
Govert

Reputation: 16907

You could add a hidden function [ExcelFunction(IsHidden=true)] to the .xll, which you can call from the VSTO add-in with Application.Run.

Upvotes: 1

Malick
Malick

Reputation: 6732

I would use a licensing system that let the user validate a licence key. This process can takes place within the VSTO. Then I would use two checks :

  1. if in the VSTO the licence key is validated then load the xll, otherwise do not load it.
  2. within the xll, by using relative path, I would locate and check a second time the licence key (to prevent that the user loads directly the xll).

It just requires to be able to check the licence key in C# (VSTO) and C (Xll), ie to have a validation key algorithm implemented in both languages.

Upvotes: 0

Related Questions