Can I use RegFree Com with an application written in Excel VBA?

廉价感情. 提交于 2019-12-23 04:28:18

问题


I have an application that is written in Excel VBA, myApp.xls. Currently we use InstallShield to distribute the application. Since we are moving to Windows Vista, I need to be able to install the application as a standard user. This does not allow for me to update the registry during the install process. In addition to the excel application we also have several VB6 applications. In order to install those applications, I was able to use RegFree com and Make My Manifest (MMM) as suggested by people on this forum (I greatly appreciate the insight btw!). This process, although a bit tedious, worked well. I then packaged the output from MMM in a VS '05 installer project and removed the UAC prompt on the msi using msiinfo.exe. Now I am faced with installing an application that basically lives in an Excel file. I modified a manifest that MMM created for me for one of my VB6 apps and tried to run the excel file through that, but I did not have much luck. Does anybody know of a way to do this? Does RegFree com work with VBA? Any thoughts or suggestions would be much appreciated.

Thanks,

Steve


回答1:


Yes, it is possible to use registration-free COM through VBA, on Win2k3+.

Fundamentally, reg-free says "this COM class no longer needs to be registered to be discoverable, instead registration info will be carried by a manifest".

Manifests themselves are implictly referenced by executables when they are embedded in the executable, or named *.exe.manifest. However, in the case of VBA -- your code doesn't live in an executable you control, so you need another way to get a reference to the manifest.

That's where the Microsoft.Windows.ActCtx object comes in - it specifically allows you to instantiate your object given an explicit manifest reference.

For example (in JS, since I'm rusty on VBA syntax):

var actCtx = WScript.CreateObject("Microsoft.Windows.ActCtx");
actCtx.Manifest = "myregfree.manifest";
var obj =  actCtx.CreateObject("MyObj");   


来源:https://stackoverflow.com/questions/707499/can-i-use-regfree-com-with-an-application-written-in-excel-vba

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