我用vb操纵Excel,利用AddPicture函数向excel中插入图片,由于图片大小不一致,因此,图片大小的参数无法精确给出,但是,我想通过vb指令,使得插入的图片能够是100%的?如何解决呢?请教!
我的方法如下:
Dim shapeCode As Excel.Shape
Set shapeCode = tt.Shapes.AddPicture(temp_finger.bmp", True, True, tt.Cells(1, 1).Left, tt.Cells(1,1).Top, 100,100)
注:100,100是随意写的,我想在这句话之后,再通过某种方法,使得插入的图片大小变成100%原始大小的?该如何做呢?

解决方案 »

  1.   

    Option ExplicitPrivate Type BITMAP '14 bytes
            bmType As Long
            bmWidth As Long
            bmHeight As Long
            bmWidthBytes As Long
            bmPlanes As Integer
            bmBitsPixel As Integer
            bmBits As Long
    End TypePrivate Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As LongPrivate Sub Command1_Click()
        Dim MyPicture As StdPicture
        Dim udtBM As BITMAP
        Dim oApp As Excel.Application
        Dim oBok As Excel.Workbook
        Dim oSht As Excel.Worksheet
        Dim oShp As Excel.Shape
        
        Set MyPicture = LoadPicture("C:\Test.bmp")
        GetObject MyPicture.Handle, LenB(udtBM), udtBM
        Set MyPicture = Nothing
        
        Set oApp = New Excel.Application
        oApp.Visible = True
        Set oBok = oApp.Workbooks.Add
        Set oSht = oBok.Worksheets(1)
        
        Set oShp = oSht.Shapes.AddPicture("temp_finger.bmp", msoFalse, msoTrue, oSht.Cells(1, 1).Left, oSht.Cells(1, 1).Top, udtBM.bmWidth, udtBM.bmHeight)
    End Sub