0

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
RealCheeseLord
  • 785
  • 1
  • 12
  • 24
Rafal
  • 11
  • 1
  • 7
  • could you add the script to your post please? also have you tried running the Job through scheduler or SQLServer, but with the workbook open? – RealCheeseLord Aug 31 '17 at 12:17
  • I have just tried running it with the workbook open and it would make no difference, the images are gone and replaced with red x. The VBS is pretty straightforward: 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 – Rafal Aug 31 '17 at 13:16
  • I managed to find a solution to this problem eventually. Having found a comment to the similar problem [here](https://stackoverflow.com/a/41161719/8543148) I found that INetCache folder was missing in the following folder: *C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows*. Once job ran, a new folder called Content.MSO folder was added by the system under newly added INetCache folder and which I believe is used to store some of the temporary files (Content.MSO that is). I made sure that the account which runs the job has permission to modify the INetCache folder. – Rafal Nov 03 '17 at 14:52

1 Answers1

0

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.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
Rafal
  • 11
  • 1
  • 7