Dim Excel As New Excel.Application
    Dim ExcelWBk As Workbook
    Dim ExcelWS As Worksheet
    '创建Excel应用程序实例
    On Error Resume Next
    Set Excel = GetObject(, "Excel.Application")
    If Err <> 0 Then
        Set Excel = CreateObject("Excel.Application")
    End If
    '打开工作簿
    If IsNull(ExcelWBk) Then
        Set ExcelWBk = Excel.Workbooks.Open("123.xls")
    End If
    Set ExcelWS = ExcelWBk.Sheets("点坐标") ' Add this sheet to this Workbook
    Dim str As String    str = ExcelWS.Cells(1, 1)  '-----------------------str总是为空    Set Excel = Nothing

解决方案 »

  1.   

    ExcelWS.Cells(1, 1)返回的好像是个Range对象吧……
      

  2.   

    首先要确认打开的sheet是否是你将要打开的sheet,就是Set ExcelWS = ExcelWBk.Sheets("点坐标") 这句,你试着用Set ExcelWS = ExcelWBk.Sheets(i),i表示sheet的id试试看。
      

  3.   

    本人已解决,原因是Isnull语句出错。谢谢楼上各位。
      

  4.   

    这是典型的On Error Resume Next引起调试困难,应在适当时候取消On Error
    ........
        On Error Resume Next
        Set Excel = GetObject(, "Excel.Application")
        If Err <> 0 Then
            Set Excel = CreateObject("Excel.Application")
        End If
        On Error GoTo 0
    ....