Excel.Application.Workbooks.Open错误 [英] Excel.Application.Workbooks.Open error

查看:857
本文介绍了Excel.Application.Workbooks.Open错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我写了一个简单的Powershell脚本来打开Excel Book,运行一个宏并退出。


我们在带有Excel 2010的Windows 10企业版上运行它。


在一台机器上它可以正常工作而另一台机器出现以下错误:
无法打开Workbooks类的属性

函数RefreshExcel {
Param($ xls)

$ Books = $ Excel .Workbooks
试试{
$ workbook = $ Books.Open($ xls)
} catch {
写$ Error [0] .ToString()
返回$ false
}
开始 - 睡眠-s 30
尝试{
$ Excel.Application.Run(" MettreAJours")
} catch {
Write $ Error [0] .ToString()
返回$ false
}
尝试{
$ workbook.save()
} catch {Return $ false}
$ workbook.close()
}

$ Excel = New-Object -ComObject excel.application
$ Excel.Visible = $ true
RefreshExcel(" ; HTTP://sharepoint.server /equipe/si/ProjectBurnDown.xlsm")
$ Excel.quit()

在两台机器上,我都可以在Excel中手动打开文件。


我已经尝试按照论坛上其他地方的建议修复Office安装,但它没有帮助。


感谢您的帮助。


H_V_L

解决方案

您好
H_V_L,


请尝试检查两个Excel是否都有相同版本的更新已安装。


如果它们不同,请尝试安装与此代码正常工作的其他计算机相同的更新。


然后尝试检查是否它是否正确运行。


还尝试检查该用户是否有足够的权限从其他计算机访问该文件。


我也发现通过在下面的位置创建文件夹的旧线程可以解决问题。


对于64位 制作此文件夹。

C:\ Windows \SysWOW64 \ config \systemprofile \Desktop



32位制作此文件夹。

C:\ Windows \System32 \ config \systemprofile \Desktop


告诉我们是否解决了您的问题。


如果问题仍然存在,我们会尝试提供进一步的建议来解决问题。


问候


Deepak


Hi,

I have written a simple Powershell Script to open a Excel Book, run a macro and exit.

We run it on a Windows 10 Enterprise with Excel 2010.

On one machine it works without error and another machine it gives the following error: Unable to get the Open property of the Workbooks class

Function RefreshExcel { 
Param ( $xls )

$Books = $Excel.Workbooks
Try {
   $workbook = $Books.Open($xls)
} catch {
    Write $Error[0].ToString()
    Return $false
}
Start-Sleep -s 30
Try {
   $Excel.Application.Run("MettreAJours")
} catch {
    Write $Error[0].ToString()
    Return $false
}
Try {
   $workbook.save()
} catch {Return $false}
$workbook.close()
}

$Excel = New-Object -ComObject excel.application
$Excel.Visible = $true
RefreshExcel("http://sharepoint.server/equipe/si/ProjectBurnDown.xlsm")
$Excel.quit()

On both machine I can open the file manually in Excel.

I have try to repair the Office installation as suggested somewhere else on the forum, but it didn't help.

Thanks for helping me.

H_V_L

解决方案

Hi H_V_L,

Please try to check that both Excel have same version of updates installed.

If they are different then try to install the same update as other machine on which this code is working.

Then try to check whether it runs correctly or not.

Also try to check that user have enough rights to access that file from other machine.

I also find in some old thread that by creating the folders on location below may solve the issue.

For 64 bit make this folder.
C:\Windows\SysWOW64\config\systemprofile\Desktop

For 32 bit make this folder.
C:\Windows\System32\config\systemprofile\Desktop

Let us know whether it solves your issue or not.

If issue persist then we will try to provide further suggestions to solve the issue.

Regards

Deepak


这篇关于Excel.Application.Workbooks.Open错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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