LotusScript Type mismatch on external name - lotus-notes

Lotus Notes 8.5.3, I am running into an issue where I cannot get the form to load the script library. I get "Type mismatch on external name: RECEIPT" (where "Receipt" is one of the types in my script library).
I have tried:
- editing and resaving the form
- editing and resaving the library
- Project > Clean, rebuilding everything
- Shutting down and restarting Notes
- Shutting down and restarting my computer
Nothing has helped.
Notes Help says that this means that a type has changed since the client of that type was compiled. I would have expected that rebuilding everything (including the form that has its Use statement) would solve it, but it doesn't.
Any suggestions?

You could try:
Open the database in the Designer client and select "Recompile all LotusScript" from the Tools menu.
Copy the code out of the script library, delete it, then create a new script library and paste the code back in.

The ultimate solution: When you have a type mismatch on an external name, comment the Use statement for the library in question from the form, then try to save it. It will fail with the first use of a class defined in the library, and prevent you from saving the form. But it will also clear the cached definitions, which will allow you to uncomment the Use statement and successfully save the form.

I would try to copy the script that uses RECEIPT into directly the library and get a clearer error message. You can try it in a copy database (not the original).
I remember in old versions of Lotus the form got crazy on libraries. But I doubt it is this case.
I suspect you are using an array of a type different that Variant and handling it to a function or sub as variant (or vice verse).
In lotus script there is CVar to convert to Variant,
In case array of objects, you might need to cast the object retrieved from an array to an Object then hand it to the function (if it has an object as parameter).

Related

Add external libraries using code in VBA for Excel

I am trying to add external libraries and use them in VBA for Excel. I have found two questions about it, but I can't get them to work in a real application.
Both of them work fine on their own, but when I try to use them in a program I get a compiler error. It seems that I cannot compile the program before I add the library (makes sense, I use unknown objects) and I cannot add the references before I compile the program.
How can I solve this?
Question 1:
Connect references (Tools>References) with VBA code (macros)
Question 2:
How to add a reference programmatically
It seems the references can be added using the Workbook_Open sub in Excel. This sub automatically runs when the workbook is opened. It works fine if it does not call any routines that use objects from the libraries that need to be added.
One of my concerns was that the macro would not run if the user has to enable macros after the book is opened. Most of the information I can find indicate that it should still run. I have not been able to test it yet though, because it seems very difficult to "untrust" a workbook to has been set to "trusted" before.

Excel changes loadbehaviour of add-in

I created an Excel VSTO add-in, which users can install. However, after using the add-in, the next time Excel is started, the add-in is no longer loaded automatically.
The user can resolve this by enabling the add-in, but it happens every time, and I would like to stop that.
What happens is that in te registry, the key:
HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\TiaGenerator\LoadBehavior is set to 2, which means inactive by default. I can change it back to 3 (load on startup), but after running Excel, it is changed back to 2.
Edit:
As #Cindy Meister said: Excel should change load behavior to 3 after startup, so there must be a problem. After some searching, it turned out the problem lies within the constructor of a self made class called ErrorWriter. The problem seems to be within this call:
Public Class Errorwriter
Inherits IO.StreamWriter
Sub New()
MyBase.New("C:\tmp\newLog.txt")
End Sub
End Class
Does anyone know why this causes Excel to change the load behavior?
Thanks to the comment of #Cindy Meister, I was able to dig a little bit deeper and here is what I found:
Apperantly, Excel changes the load behaviour of an Add-in if it encounters an unhandled exception during startup.
In the startup routine, I create a new instance of an 'ErrorWriter' object, which inherits from 'StreamWriter', and uses a reference to this file.
What happens is that Excel is loaded, an locks this file. Upon using some functions of this add-in, a second Excel instance is started in the background, which tries to use this file as well. This results in an unhandled exception, but because this second instance is not visible, this error is never shown to the user (nor the programmer).
Because the ErrorWriter is not needed in the second instance of Excel, it never becomes clear that the error occeured in any way.
This causes Excel to change its load behavior.
It is fixed by moving the offending code into a seperate function, which is only called upon invoking add-in functions.
I have thoroughly investigated the problem and found a solution. Changing the "LoadBehavior" is the right way of doing it, but you have to be careful about one thing. Both Outlook or Excel restore the previous settings for each add-in. BUT not at the start of the add-in but AFTER the add-in's start up.
In other words if you attempt to change the LoadBehavior in Windows Registry as part of the startup it will never work. You have to do it afterwards.
I hope this will help.
Thank you, VJ

Keep custom functions aligned with their source files

In this link, it says that
During development and testing, you can manually clear your computer's cache of registration metadata by deleting the folder <user>\AppData\Local\Microsoft\Office\16.0\Wef\CustomFunctio‌​ns.
I then make a test as follows:
I load a manifest.xml pointing to the original customfunctions.js in my server in a workbook. After closing the workbook, a file is automatically saved in ...\Wef\CustomFunctio‌​ns\V1.
I modify manually customfunctions.js in my server by replacing Excel.Script.CustomFunctions["CONTOSO"]["ADD42"] by Excel.Script.CustomFunctions["CONTOSO"]["ADD42NEW"].
I open a new workbook, in a cell, after enter =contoso., the IntelliSense shows me contoso.add42 rather than add42new. After entering =contoso.add42(5;4), the cells shows #GETTING_DATA and does not return a value. That's understandable because it works on a function which does not exist anymore.
If we click on another cell and enter e.g., =2+3, we see the workbook is refreshed, and #GETTING_DATA becomes #NAME?. And now IntelliSense shows contoso.add42new rather than contoso.add42.
To conclude, I think there may be a bug: when we open a workbook, IntelliSense should give the updated list of custom functions defined in the current customfunctions.js.
Actually, what is ideal is that the custom functions in workbook always keep aligned with what are defined in customfunctions.js. If there was not this bug, today we still needed to close a workbook and reopen one to get updated. Does anyone know if there is a workaround to make custom functions in an opened workbook keep updated on the fly? Is there a refreshing trigger that allows us to make custom functions in an opened workbook update from the current customfunctions.js?
Thanks for the question! As you've discovered, custom function definitions are currently updated only on-demand rather than on every single document-open event.
We've received a bunch of feedback in this area and so we're considering some changes to how registration works so that the list of functions in IntelliSense/autocomplete gets updated at the beginning of a session instead of in the middle of one.
I don't have details to share right now, but be on the lookout for some changes here in a few months.

lotus notes signature error, "must chose filename"

who in the pass tried to add an image to her signature, not too sure how she's done it but now she cant change her signature.
I used to be able to force it using the webmail signature function but thats not working anymore and anyway im way over due to fix this problem.
everytime she opens her preferences and when we want to modify her signature i have a popup windows that tells me :
field contains incorect value
“since you have chosen to append and HTML or image as a signature, you must include the filename that you wish to use.”
if i uncheck the "automaticaly add signature" option i dont get this error but as soon i re check it i get the window, even if theres nothing in the signature window, i've deleted everything in the text box same problem.
I reinstalled windows on another computer with our Ghost image, and on this clean install she has the same error so i guess its saved somewhere on my domino server
thanks a million.
Probably an error in her calendar profile. Use some tool to edit her calendar profile directly or just delete it.

Expanding Custom Class node in Locals window silent crashes excel

The issue:
Similar to this issue but unable to find a solution I am trying to figure out how to fix this bug:
Viewing an object in Locals or Watch window causes excel to crash
The custom class is as wrapper for ADO execution allowing us to use a separate class to maintain our SQL code and execute it within the wrapper to keep error handling for MS Access ADO execution in one neat place.
This has been great for logging and debugging purposes until a few days ago I noticed trying to expand the node for the custom class in the Locals or Watch windows in the VBA editor cause Excel to silent crash after a 5 second hang and restart with the file recovery window.
Unfortunately the code is company sensitive so I may not be able to paste any in but if there are any ideas as to what might cause it I may be able to find the source and report back.
Has anyone else experienced this issue?
Update: New symptom - During debugging and comparing the text between an older build and the new one I found that the Locals window goes empty (clears of all objects) just after the hang stops and before the crash occurs.
Fixes I have tried:
Rebuilding VBA project and fixing all known compile errors (to eliminate simple vba errors)
Exporting all classes and modules - reimporting into new workbook (to eliminate the workbook file being corrupt)
Copying class and module text into notepad and clearing all formatting - pasting into new workbook (in an attempt to remove corrupt class data)
Disabling any reference to other custom classes to narrow down to a single class.
I appreciate your help and hope my issue can shed some light on it for others.
You can try below things. I hope any one of them work for you. If it still it does not works i request you to
simulate the similar issue for demo and share the code.
Possible issues with add-ins. Try to remove your addins (uninstall
the com addins) and run the code and check if you are still having
the issue.Disabling add-ins is a good test because it let you narrow
the choice of which add-in is causing the crash.
Check whether your antivirus software is up to date or is conflicting
with Excel. If your antivirus software is not up to date, Excel may
not function correctly.
Kindly run the macro on single instance of excel and check if you are
still having the issue. By single instance i mean when you go to task
manager processes tab where only one image name with excel.exe should
appear.
Verify/install the latest window updates
Try to run the same macro on other pc or other version of excel
Use mztools andin and review your code

Resources