我写个程序,其中调用excel时,别人的机器报自动化错误(该机器装了excel),我已经打包,而且其他机器可以运行.请问是什么原因

解决方案 »

  1.   

    可以看看你的那段调用EXCEL的程序吗,可能是不兼容而导致的吧.
      

  2.   

    是不是你的excel没有引用某些宏
      

  3.   

    可以参考这样的程序:Dim Excel As Excel.Application ' This is the excel program
    Dim ExcelWBk As Excel.Workbook ' This is the work book
    Dim ExcelWS As Excel.Worksheet ' This is the sheetPrivate Sub StartExcel()
    On Error GoTo err:
       
        Set Excel = GetObject(, "Excel.Application") ' Create Excel Object.
        'Excel.Visible = True ' Show Excel
        Exit Sub
    err:
        Set Excel = CreateObject("Excel.Application") 'Create Excel Object.
    End Sub '启动excel程序
        Call StartExcel
        Set ExcelWBk = Nothing
        Set ExcelWS = Nothing
        Set ExcelWBk = Excel.Workbooks.Add    'Add this Workbook to Excel.
        Set ExcelWS = ExcelWBk.Worksheets("sheet1") ' Add this sheet to this Workbook
        'ExcelWBk.Worksheets("sheet1").name = "Data"
        Excel.Visible =true