VBA Error 1004 : Method “Close” of Chart.ChartData.Workbook object Failed

元气小坏坏 提交于 2020-05-14 09:04:09

问题


I have a macro that updates a ppt presentation charts from a monthly updated Excel file. It has been working like a charme for a couple of months. Since a few days ago, I have a problem to close the charts Workbook after updating their numbers and I get a 1004 runtime error.

Here is the code :

    With .Slides(1).Shapes("gmbDiscoveryRateChart").Chart.ChartData
    .Activate
    .Workbook.Sheets(1).Range("B2").value = currentGmbDiscoveryRate
    .Workbook.Sheets(1).Range("B3").value = 1 - currentGmbDiscoveryRate
    .Workbook.Close '<-- Error here
    End With

回答1:


It seems that there is a bug in PowerPoint or Excel. I had the same issue and I disabled automated updates in Office 365 (File -> Account -> Office Updates) and reverted it to version 16.0.11629.20214 (June 2019).

CMD as admin:

cd %programfiles%\Common Files\Microsoft Shared\ClickToRun\
OfficeC2RClient.exe /update user updatetoversion=16.0.11629.20214

I hope it helps.




回答2:


Try Workbook.Application.Quit It might help.



来源:https://stackoverflow.com/questions/61226735/vba-error-1004-method-close-of-chart-chartdata-workbook-object-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!