Rafal
Rafal

Reputation: 41

Excel workbook loses images after being refreshed through task scheduler job or SQL Server agent job

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.

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

Upvotes: 0

Views: 285

Answers (1)

Rafal
Rafal

Reputation: 41

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.

Upvotes: 0

Related Questions