Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBScript create excel 2016 object

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?

like image 536
Ray Lin Avatar asked Jan 18 '18 15:01

Ray Lin


2 Answers

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.

like image 137
Andy G Avatar answered Oct 23 '22 21:10

Andy G


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")

like image 39
Tarun Lalwani Avatar answered Oct 23 '22 21:10

Tarun Lalwani