我的代码是
var   excelOBJ=new   ActiveXObject("Excel.Application");   
  excelOBJ.WorkBooks.Add; 
  var msoShapeRectangle=1;
  excelOBJ.ActiveSheet.Shapes.AddShape(msoShapeRectangle, 40, 80, 140, 50).Fill.UserPicture("d://1.gif"); 其中140是宽度,50是高度,但是这2个值不是1.gif的实际大小
我想在导入excel前能得到1.gif的实际大小
请高手指点,谢谢

解决方案 »

  1.   


    var oIE = new ActiveXObject("InternetExplorer.Application");
    oIE.Navigate("file:///D:/1.gif");
    SynchronizeIE();
    oIE.Visible = false;
    var img = oIE.Document.getElementsByTagName("image")[0];
    alert(img.width);
    alert(img.height);
    oIE.Quit();function SynchronizeIE(){
    while(oIE.Busy){
    WScript.Sleep(100)
        }
    }function alert(s){WScript.Echo(s);}
      

  2.   

    顺便提个VB的做法:
    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".jpg").Select  'Insert Pictures"
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".jpeg").Select  'Insert Pictures"
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".gif").Select  'Insert Pictures"
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".jpe").Select  'Insert Pictures"
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".BMP").Select  'Insert Pictures"
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".BMP").Select  'Insert Pictures"
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".BMP").Select  'Insert Pictures"
       ActiveSheet.Pictures.Insert("C:\temp\" & Target.Text & ".BMP").Select  'Insert Pictures"
       Selection.Name = Target.Text    'Picture name
       Selection.ShapeRange.LockAspectRatio = msoFalse '
       Selection.ShapeRange.Height = Target.Height  'H
       Selection.ShapeRange.Width = Target.Width  'W
       Selection.ShapeRange.Top = Target.Top  'Top
       Selection.ShapeRange.Left = Target.Left  'Left
    End Sub