调用Workbooks.Add()时使用Powershell自动执行Excel 2007的异常 [英] Exception automating Excel 2007 with Powershell when calling Workbooks.Add()

查看:133
本文介绍了调用Workbooks.Add()时使用Powershell自动执行Excel 2007的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在Powershell V1(Excel 2007)中引发异常:

The following code throws an exception in Powershell V1 (Excel 2007):

$E = New-Object -COM "Excel.Application"
$E.Visible = $True
$wb = $E.Workbooks.Add() #<<<Exception here

该错误表明格式可能过旧或类型库无效(从西班牙语翻译).类似的Word脚本也可以正常工作.

The error says that the format might be old or that the type library is not valid (translated from Spanish). A similar script for Word works just fine.

推荐答案

来自同一篇文章:

当您使用以下变通办法之一进行计算机的区域设置时 与当前的Office语言版本不匹配,您应该熟悉 Excel的行为方式以及Excel将如何解释可能会格式化的数据 特定的语言环境.

When you use one of these workarounds for a computer where the regional settings do not match the current language version of Office, you should be familiar with how Excel behaves and how Excel will interpret data that might be formatted for a specific locale.

这篇关于调用Workbooks.Add()时使用Powershell自动执行Excel 2007的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆