I have a VbScript file which uses CreateObject("Excel.Application")
to launch Excel then run a macro. This way, excel-based batches can be run without relying on Workbook_open methods.
我有一个VbScript文件,它使用CreateObject(“Excel. application”)启动Excel,然后运行一个宏。这样,可以在不依赖Workbook_open方法的情况下运行基于excel的批次。
The ideal solution, at least for a transitional period, would be to have some jobs running on Excel 2003 and others on 2010.
理想的解决方案,至少在过渡时期,将会有一些工作在Excel 2003和其他2010年。
I've looked in the registry for a way to force a particular version, but this doesn't seem to be working. It wouldn't be ideal to be using the registry anyway, because two jobs could be running concurrently.
我在注册表中查找了强制执行某个特定版本的方法,但这似乎并不奏效。无论如何,使用注册表并不理想,因为两个作业可以同时运行。
Is there a way to target a specific version in VbScript?
在VbScript中有针对特定版本的方法吗?
1 个解决方案
#1
1
It is not possible to do this easily. The registry will associate "Excel.Application" with a particular excel.exe and changing that mid-session may cause problems.
要做到这一点是不可能的。注册表将关联“Excel”。应用程序"与特定的excel。exe和更改会话中期可能会导致问题。
You could try building your own COM object (you need to do that since you can't call DLL functions directly in VBScript) which will call regsvr on a particular version of excel. You will have to control that carefully: ensure you do this before creating an "Excel.Application" object. My hypothesis is that, after that, you're free to change the registry with a second call to regsvr via your COM object. Someone may have even written a COM-based regsvr already. And testing it would be trivial.
您可以尝试构建自己的COM对象(您需要这样做,因为不能直接在VBScript中调用DLL函数),它将在特定版本的excel上调用regsvr。您必须小心地控制这一点:在创建“Excel”之前,请确保这样做。应用程序”对象。我的假设是,在此之后,您可以通过您的COM对象对regsvr进行第二次调用来更改注册表。有人甚至可能已经编写了基于com的regsvr。测试它是很简单的。
This approach might work: to my knowledge the CoClass GUIDs are only required by the COM factory. And subsequent queryInterface calls implicitly called by the VBScript runtime will rely on the interface UUIDs which will be consistent across the two versions. But my fear is that it would be too brittle to be useful in production.
这种方法可能会奏效:据我所知,CoClass gui只需要COM工厂。VBScript运行时隐式调用的后续queryInterface调用将依赖于接口uuid,它将在两个版本之间保持一致。但我担心的是,它太脆了,不适合生产。
The easiest thing to do, as I'm sure you know, would be to have two machines!
我相信你知道,最简单的事情就是拥有两台机器!
#1
1
It is not possible to do this easily. The registry will associate "Excel.Application" with a particular excel.exe and changing that mid-session may cause problems.
要做到这一点是不可能的。注册表将关联“Excel”。应用程序"与特定的excel。exe和更改会话中期可能会导致问题。
You could try building your own COM object (you need to do that since you can't call DLL functions directly in VBScript) which will call regsvr on a particular version of excel. You will have to control that carefully: ensure you do this before creating an "Excel.Application" object. My hypothesis is that, after that, you're free to change the registry with a second call to regsvr via your COM object. Someone may have even written a COM-based regsvr already. And testing it would be trivial.
您可以尝试构建自己的COM对象(您需要这样做,因为不能直接在VBScript中调用DLL函数),它将在特定版本的excel上调用regsvr。您必须小心地控制这一点:在创建“Excel”之前,请确保这样做。应用程序”对象。我的假设是,在此之后,您可以通过您的COM对象对regsvr进行第二次调用来更改注册表。有人甚至可能已经编写了基于com的regsvr。测试它是很简单的。
This approach might work: to my knowledge the CoClass GUIDs are only required by the COM factory. And subsequent queryInterface calls implicitly called by the VBScript runtime will rely on the interface UUIDs which will be consistent across the two versions. But my fear is that it would be too brittle to be useful in production.
这种方法可能会奏效:据我所知,CoClass gui只需要COM工厂。VBScript运行时隐式调用的后续queryInterface调用将依赖于接口uuid,它将在两个版本之间保持一致。但我担心的是,它太脆了,不适合生产。
The easiest thing to do, as I'm sure you know, would be to have two machines!
我相信你知道,最简单的事情就是拥有两台机器!