如何在VBscript中调用2010 excel.xlsm而不是2003?

时间:2016-01-14 10:18:13

标签: excel vba vbscript excel-2010

1)我希望在excel 2010而不是2003年开放 Dim objExcel,objWorkbook

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("\\filepath.xls ")
objExcel.Visible = True
objExcel.Run "Test2"                                                     ‘Running a macro
objworkbook.Save

objWorkbook.Close False

objExcel.Quit


'Set objWorkbook = Nothing
'Set objExcel = Nothing

WScript.Quit

2)如何将文件指定为具有已定义名称的excel文件 - 这样我就可以运行宏,保存并关闭代码

Dim sXLPath
Set sXLPath = WScript.CreateObject ("WScript.Shell")
sXLPath.run "cmd.exe cd /C C:\WINDOWS\CCM\Launcher.exe /launch ""Microsoft Excel 2010"" "

WScript.Sleep 15000 'Sleeps for 15 seconds

CreateObject("WScript.Shell").Run("""\\filepath.xls""")

1 个答案:

答案 0 :(得分:0)

您可以在GetObject调用期间指定版本

  Set app = CreateObject("Excel.Application.15") '2013
  Set app = CreateObject("Excel.Application.14") '2010
  Set app = CreateObject("Excel.Application.12") '2007
  Set app = CreateObject("Excel.Application.11") '2003