Remove AddIn path from UDF in Excel formula

风格不统一 提交于 2019-12-18 08:59:05

问题


My addin was xla, now I use excelDNA, so it becomes xll, When I open spreadsheet built in previous version of My addin, for the UDF, it shows myUDF with path of xla. e.g "C:\Program Files\Installation folder\MyUDFs.xla!MyUDF", when I click Edit link and change source to "C:...\MyUDFs.xll" I got a pop up which says "Excel cannot update one or more links in this workbook. To update the links, open all the link source files(click Edit Links on the Data tab). To be sure all calculations are updated. press F9" I click OK, then the path of MyUDF changes from xla to xll, e.g. C:\Program Files\Installation folder\MyUDFs.xll!MyUDF For clients, this will break all their spreadsheets (could be 100+) built in previous version. I know I can write a VBA code to remove paths from all MyUDF. but it is not ideal since users have to open up spreadsheet and put the code in spreadsheet and run.

I wonder if there is a better/more convenient way for clients to solve the issue thanks


回答1:


Internally, Excel stores different information for an .xla function and an .xll function. It's not so easy to around so that you can make an .xll that is compatible with functions that were entered into the sheet as functions in an .xla.

You can also see how Excel stores this information by poking around inside the .xmlx file a bit.

This Wilmott discussion might be relevant: http://www.wilmott.com/messageview.cfm?catid=10&threadid=79763 For your case the best I can suggest is adding a conversion macro to your .xll, and having the user press the 'Fix-up' button when they open spreadsheets that have not been converted yet.




回答2:


This is the solution I use at last. I keep my xla addin, in xll, I register the same MyUDF with the same sigature(while, almost the same, optional parameters are not supported in xll, but are used in my xla) and set IsHidden = true. So there is only one MyUDF shows up in insert function list. When you type in =MyUDF and click function wizard, the version in xll shows up in function argument window. In Excel 2007, when I type =MyUDF, there is no function in drop down. In Excel 2010, when I type =MyUDF, there is a drop down. So the solution works better in Excel 2010.



来源:https://stackoverflow.com/questions/6414719/remove-addin-path-from-udf-in-excel-formula

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!