Home » excel » VBScript create excel 2016 object

VBScript create excel 2016 object

Posted by: admin March 9, 2020 Leave a comment

Questions:

I have two versions of excels(2010 and 2016) installed on my machine. I would like to run a vbscript on excel 2016.

However, the

CreateObject("Excel.Application") 

only creates excel 2010. How can i change this to 2016?

How to&Answers:

I believe the issue you may be running into is of 32bit and 64bit.

32bit: c:\Windows\SysWOW64\wscript.exe
64bit: c:\Windows\System32\wscript.exe

When you run a 32bit vbscript process (the default) the mapping automatically takes the 32bit excel version.

So you should try running it with the 64bit VBScript

And yes you would want to use CreateObject("Excel.Application.16")

Answer:

For 2016, you could try CreateObject("Excel.Application.16").

However, see the comments below as this is not guaranteed to work for recent versions. This has worked for me before for versions up-to and including 2010.

Note that earlier versions don’t have such a straightforward correspondence, 2016 => 16. For example, I believe Office 2010 => 14.