Excel 2002 and the .emf files

  • Thread starter Thread starter Joshua Campbell
  • Start date Start date
J

Joshua Campbell

I have a program that starts an instance of Excel 2002, creates a
spreadsheet, prints it, and closes. It does this roughly 400 times a day.
As you can imagine, this means that a lot of .emf files are going to be
created by Excel, and this can fill up a hard drive if left unchecked. Is
there a way to keep Excel from creating these files?

Thanks.
Joshua
 
I assume you mean the EMF files generated by excel
in the temp folder?

These files are generated only/mostly?
for embedded controls on worksheets.

So your code may create sheets with embedded controls?


Either:
get rid of the embedded controls and replace
with native controls from the form toolbar.


close excel properly when your routine finishes.
when excel is closed (not Terminiated via API)
it should (and normally does) clear up any
mess left in the temp dir.


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Yes, in the TEMP folder. Sorry for not being specific.

To the best of my knowledge, I am not creating any embedded controls.

In my VB.NET app, I have the following commands:
xlbook.Close(False)
xlapp.Quit()
'Release the references we have

System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsheet)

System.Runtime.InteropServices.Marshal.ReleaseComObject(xlbook)

System.Runtime.InteropServices.Marshal.ReleaseComObject(xlapp)

Did I not close something properly?
 
I'm an old VBA hack and I haven't yet found it necessary to
migrate to .Net interops etc. <g>

although your code makes sense to me..



I'd test following:

clean the temp.
run your code.
check the temp.. and open the emf files to see what they are..
(and check that they are in fact generated by your code...


that's it for me..





keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Apparently, the problem does lie in bad code. My code basically puts data
from an array into various cells, gives the worksheet a background, prints
the sheet, and closes. The mso*.emf file that is left is a copy of the
background image. Weird. Oh well. I'll probably just create a scheduled
task then to delete these files on a regular basis.

Thanks for your help!
Joshua
 
Back
Top