可以将图像从excel导出到tif文件吗?

时间:2019-04-12 05:02:05

标签: excel vba

这是我的代码将图像从excel导出到文件

For Each oShape In ActiveSheet.Shapes
    strImageName = oShape.TopLeftCell.Row & "_" & oShape.TopLeftCell.Column
    If oShape.Type = msoPicture Then
        oShape.Select
        'Picture format initialization
        Selection.ShapeRange.PictureFormat.Contrast = 0.5: Selection.ShapeRange.PictureFormat.Brightness = 0.5: Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic: Selection.ShapeRange.PictureFormat.TransparentBackground = msoFalse: Selection.ShapeRange.Fill.Visible = msoFalse: Selection.ShapeRange.Line.Visible = msoFalse: Selection.ShapeRange.Rotation = 0#: Selection.ShapeRange.PictureFormat.CropLeft = 0#: Selection.ShapeRange.PictureFormat.CropRight = 0#: Selection.ShapeRange.PictureFormat.CropTop = 0#: Selection.ShapeRange.PictureFormat.CropBottom = 0#: Selection.ShapeRange.ScaleHeight 1#, msoTrue, msoScaleFromTopLeft: Selection.ShapeRange.ScaleWidth 1#, msoTrue, msoScaleFromTopLeft
        '/Picture format initialization
        Application.Selection.CopyPicture
        Set oDia = ActiveSheet.ChartObjects.Add(0, 0, oShape.Width, oShape.Height)
        Set oChartArea = oDia.Chart
        oDia.Activate
        With oChartArea
            .ChartArea.Select
            .Paste
            .Export ("D:\images\" & strImageName & ".jpg")
        End With
        oDia.Delete 'oChartArea.Delete
    End If
Next

如果我导出为jpg,png,gif,bmp,则此代码可以正常工作。

但是它不能导出到tif文件。

可以将图像从excel导出到tif文件吗?

如何处理?

谢谢。

0 个答案:

没有答案