这段代码使用的是OWC10.ChartSpace,
Function ResizeImage(FileName, OutFormat)
Dim Chs, chConstants, rsSave
'获取图片宽高
Dim rsPict, FSO, objShell, objFolder, objItem, strWidth, strHeight, strW, strH, strSize, strS
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(FSO.GetParentFolderName(FileName))
Set objItem = objFolder.ParseName(FSO.GetFileName(FileName))
strWidth = objFolder.getdetailsof(objItem, 27)
strHeight = objFolder.getdetailsof(objItem, 28)
strW = Split(strWidth, " ")
strH = Split(strHeight, " ")
If strW(0) > 200 Then
strWidth = 150
strHeight = strH(0) * 150 / strW(0)
End If
If strHeight > 200 Then
strHeight = 200
strWidth = strW(0) * 200 / strH(0)
End If
'Create an OWC chart object
strS=filename
Set Chs = CreateObject("OWC10.ChartSpace")
Set chConstants = Chs.Constants
'Set background of the chart
Chs.Interior.SetTextured strS, 5, , 7
Chs.border.Color = -3
'export the picture to a file
'Chs.ExportPicture OutFileName, OutFormat, Width, Height
'or return it as a binary data for BinaryWrite
ResizeImage = Chs.GetPicture(OutFormat, strWidth, strHeight)
'rsSave = Chs.exportpicture(FileName, "jpg", Width, Height)
End Function