Unregistering the Xll

121 görüntüleme
İlk okunmamış mesaja atla

ajwillshire

okunmadı,
18 Tem 2011 11:11:5918.07.2011
alıcı Excel-DNA
Hi,

I know this has come up in a few other threads already (sometimes
almost as a side topic) but I've had trouble getting it to work with
my application and I'm wondering if I'm doing something wrong.

When my add-in is loaded I've got it to read a text file (as a
licence), decode it, check it's valid and set a global constant to
True or False.

If it's false I want it to show a message and then effectively unload
itself so that the functions are not available to be used.

Here's my code (VB) using what I've picked up from other threads:

---------------------------------------------------------------------------------------------------------------------------

Public Sub AutoOpen() Implements
ExcelDna.Integration.IExcelAddIn.AutoOpen

If LicenceBoolean Then
'MsgBox("Hello - This is correctly licenced", vbOK)

Else

MsgBox("This add-in is not licenced - please contact XXX
for more information.", vbOK)
RemoveMe()

End If

End Sub


Public Sub AutoClose() Implements
ExcelDna.Integration.IExcelAddIn.AutoClose

MsgBox("Goodbye World", vbOK)

End Sub


Private Sub RemoveMe()

Dim myName As String =
DirectCast(XlCall.Excel(XlCall.xlGetName), String)
Dim removeId As Object = XlCall.Excel(XlCall.xlfRegister,
myName, "xlAutoRemove", "I", ExcelMissing.Value, ExcelMissing.Value,
2)
Dim removeResult As Object = XlCall.Excel(XlCall.xlfCall,
removeId)
Dim removeUnregister As Object =
XlCall.Excel(XlCall.xlfUnregister, removeId)

End Sub

---------------------------------------------------------------------------------------------------------------------------

Thanks,
Andrew

ajwillshire

okunmadı,
18 Tem 2011 11:31:2718.07.2011
alıcı Excel-DNA
Sorry forgot to spell out the problem exactly...

The licencing bit works, I get all the expected goodbye messages etc.,
but the functions are still available in Excel.

Govert van Drimmelen

okunmadı,
18 Tem 2011 12:25:5218.07.2011
alıcı Excel-DNA
Hi Andrew,

I think the registration is only happening after AutoOpen().
So you'll have to call your license check in a different macro, after
the AutoOpen() has completed.

You could set up an OnTime call, or try Application.Run from a new
thread or something.

I did manage to crash Excel by trying to unloading 'myself' using
XlCall.Excel(XlCall.xlfUnregister, pathToMe).

-Govert

ajwillshire

okunmadı,
19 Tem 2011 08:46:2119.07.2011
alıcı Excel-DNA
I think I was basing the method on the one here:

http://groups.google.com/group/exceldna/browse_thread/thread/78c1c16bb43e3ec2/

but using the licence check instead of the message box.

If I have any luck with another approach I'll post it in here.

Thanks.
> > but the functions are still available in Excel.- Hide quoted text -
>
> - Show quoted text -

Govert van Drimmelen

okunmadı,
24 Tem 2011 12:26:0424.07.2011
alıcı Excel-DNA
Hi Andrew,

I made some changes in v 0.29 that broke the unregister-from-AutoOpen.

A bit more info and a workaround for v. 0.29 is in this thread:
http://groups.google.com/group/exceldna/browse_thread/thread/57f13ca6180eb7f7.

-Govert

On Jul 19, 2:46 pm, ajwillshire <ajwillsh...@hotmail.co.uk> wrote:
> I think I was basing the method on the one here:
>
> http://groups.google.com/group/exceldna/browse_thread/thread/78c1c16b...
Tümünü yanıtla
Yazarı yanıtla
Yönlendir
0 yeni ileti