I found a code snippet that opens a workbook and creates a temp gif image to display on a form. I have modified it a bit and it is pretty good, ( I pass a password as the workbook is protected and I created a tempvar to store the strfile so that I can delete it when Im done with it) but I have ran into a few issues.
If the workbook at more than 3-4 graphs the script does not return the image; instead it returns a error 2114. I ended up having to create several individual excel documents with 3 graphs each. Is that a limitation of excel or access or windows or the snippet? Thoughts?
If the workbook at more than 3-4 graphs the script does not return the image; instead it returns a error 2114. I ended up having to create several individual excel documents with 3 graphs each. Is that a limitation of excel or access or windows or the snippet? Thoughts?
VBA Code:
dim newapp as object
set newapp=createobject("excel.application")
dim wb as object
dim ws as object
dim ct as object
dim strFile as string
set wb=newapp.workbooks.open("workbook path")
set ws=wb.sheets(1)
set ct=ws.chartobjects(1) 'sometimes you have to put .chartobjects(1).chart
strFile=environ("temp") & "\" & format(now,"mmddyyhhmmss") & ".GIF"
ct.export strfile,FilterName:="GIF"
Me.NameOfAnImageControl.Picture = strFile
Me.Repaint