Public Function IntToAsc(I As Integer) As String
    Dim LenI As Integer
    Dim Str As String
    LenI = IIf(I / 26 > 1, 2, 1)
    Select Case LenI
        Case 1
            IntToAsc = Chr(Asc("A") + I - 1)
        Case 2
            IntToAsc = Chr(Asc("A") + Int(I / 26) - 1) & Chr(Asc("A") + IIf((I Mod 26 - 1) < 0, 0, I Mod 26 - 1))
    End Select
End FunctionPrivate Sub FB_Export_Click()
    Dim AppExcel As Excel.Application
    Dim row_t As Long
    Dim Str_Count As String
    Dim Strtmp As String
    Dim Field_Print_Count As Integer
    Set AppExcel = New Excel.Application
    Field_Print_Count = 0
    row_t = 1
    Field_Print_Count = 0
    AppExcel.Workbooks.Add
    Str_Count = Check_field.Count
    For I = 1 To Str_Count - 1
            If Check_field(I).Value = 1 Then
               'Rst_tt.Fields(I - 1).Value
                Field_Print_Count = Field_Print_Count + 1
'                Arr_Field(Field_Print_Count) = Rst_tt.Fields(I - 1)
            End If
            I = I + 1
    Next I
    
    
    With AppExcel
        Strtmp = "A" & row_t & ":" & IntToAsc(Field_Print_Count) & row_t
        .Range(Strtmp).Merge
        .Range(Strtmp).HorizontalAlignment = xlCenter
        .Range(Strtmp).Font.Size = 12
        .Range(Strtmp).RowHeight = 20
        .Range(Strtmp).Value = "人事信息"
        row_t = row_t + 1
        
        Strtmp = "A" & row_t & ":" & IntToAsc(Field_Print_Count) & row_t
        .Range(Strtmp).Font.Size = 10
        .Range(Strtmp).RowHeight = 25
        .Range(Strtmp).HorizontalAlignment = xlCenter
        .Range(Strtmp).WrapText = True
        Dim J As Integer
        J = 1
        I = 1
        Do While I < Str_Count - 1
             If Check_field(I).Value = 1 Then
                Strtmp = IntToAsc(J) & row_t
                .Range(Strtmp).Value = Check_field(I).Caption
                J = J + 1
             End If
             I = I + 1
        Loop
        row_t = row_t + 1
        Rst_tt.MoveFirst
        Do While Not Rst_tt.EOF
            J = 1
            I = 1
            Do While I <= Str_Count - 1
                If Check_field(I).Value = 1 Then
                    Strtmp = IntToAsc(J) & row_t
                    If I = 1 Then
                        Dim str_temp As Integer
                         str_temp = Rst_tt.Fields(0).Value
                        .Range(Strtmp).value= str_temp                    Else
                         .Range(Strtmp).Value = Rst_tt.Fields(I - 1).Value
                    End If
                    J = J + 1
                End If
                I = I + 1
            Loop
            row_t = row_t + 1
            Rst_tt.MoveNext
        Loop
        
    End With请大家看看,以下两段代码有何区别,为什么下面这一段不行?其中,记录集第0域的字段
为id,自动编号。数据库为Sqlserver数据库。
'************************为什么需要用变量来传值才不会出错******
                         Dim str_temp As Integer
                         str_temp = Rst_tt.Fields(0).Value
                        .Range(Strtmp).value= str_temp
'**直接用以下句子来写,为什么不行,出错信息:实时错误,要求对象424******
'                       .range(strtmp).value=rst_tt.fields(0).value
                '        .range(strtmp).value=rst_tt.fields("id").value
'**********************************************************