通过任务计划程序作业或SQL Server代理程序作业刷新后,Excel工作簿将丢失图像

时间:2022-10-17 02:13:52

When I refresh my Excel 2010 workbook using the Task Scheduler job or the SQL Server agent job, all images in the workbook are replaced with the red x. Both jobs call VBS script which runs a macro within the workbook. When I run that VBS script manually (by simply executing the script) there is no issue. What could be the reason and how can I fix it? I tried amending permissions on the Content.MSO folder for various users and nothing helps.

当我使用任务计划程序作业或SQL Server代理程序作业刷新Excel 2010工作簿时,工作簿中的所有图像都将替换为红色x。这两个作业都调用VBS脚本,该脚本在工作簿中运行宏。当我手动运行该VBS脚本(通过简单地执行脚本)时,没有问题。可能是什么原因,我该如何解决?我尝试为各种用户修改Content.MSO文件夹的权限,没有任何帮助。

Code:

码:

Set objExcel = CreateObject("Excel.Application.14") 
Set objWorkbook = objExcel.Workbooks.Open("D:\Files In\test.xlsm")
   objExcel.Application.Visible = False 
   objExcel.Application.Run "'test.xlsm'!MAIN_MACRO"   
   objExcel.ActiveWorkbook.Save 
   objExcel.ActiveWorkbook.Saved = True 
   objExcel.ActiveWorkbook.Close(0) 
   objExcel.Quit 
Set objExcel = Nothing 
WScript.Quit

1 个解决方案

#1


0  

I made a comment under my own question which is also an answer to my problem. I want to mark this question as answered (although it looks a bit suspicious that I have answered my own question and marked it correct but can't see any other way to close it).

我根据自己的问题发表评论,这也是我问题的答案。我想把这个问题标记为已回答(虽然看起来有点怀疑我已经回答了我自己的问题并将其标记为正确但却看不到任何其他方式来关闭它)。

The issue was a missing folder called INetCache in the following location: C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Micro‌soft\Windows As soon as I created it and also added permissions to it to the user which runs the job (I did not test if setting permissions was really required), once the job ran, a new folder called Content.MSO was created by the system under INetCache and my Excel report retained all of its original images and icons that were embedded inside it.

问题是在以下位置丢失了一个名为INetCache的文件夹:C:\ Windows \ SysWOW64 \ config \ systemprofile \ AppData \ Local \ Microsoft \ Windows我创建它时,还向运行该作业的用户添加了权限(我没有测试是否确实需要设置权限),一旦作业运行,系统在INetCache下创建了一个名为Content.MSO的新文件夹,我的Excel报告保留了嵌入其中的所有原始图像和图标。

#1


0  

I made a comment under my own question which is also an answer to my problem. I want to mark this question as answered (although it looks a bit suspicious that I have answered my own question and marked it correct but can't see any other way to close it).

我根据自己的问题发表评论,这也是我问题的答案。我想把这个问题标记为已回答(虽然看起来有点怀疑我已经回答了我自己的问题并将其标记为正确但却看不到任何其他方式来关闭它)。

The issue was a missing folder called INetCache in the following location: C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Micro‌soft\Windows As soon as I created it and also added permissions to it to the user which runs the job (I did not test if setting permissions was really required), once the job ran, a new folder called Content.MSO was created by the system under INetCache and my Excel report retained all of its original images and icons that were embedded inside it.

问题是在以下位置丢失了一个名为INetCache的文件夹:C:\ Windows \ SysWOW64 \ config \ systemprofile \ AppData \ Local \ Microsoft \ Windows我创建它时,还向运行该作业的用户添加了权限(我没有测试是否确实需要设置权限),一旦作业运行,系统在INetCache下创建了一个名为Content.MSO的新文件夹,我的Excel报告保留了嵌入其中的所有原始图像和图标。