Results 1 to 24 of 24

Thread: [RESOLVED] First thread in this site, problem with reading from excel,help~

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    28

    Resolved [RESOLVED] First thread in this site, problem with reading from excel,help~

    Firstly I have to tell u that I am a Chinese boy, so maybe I will not quite understand what u experts have responded and ask again for solution, sorry for that.
    Well, to the problem. I am trying to read from an Excel file including 2 cols and unsure rows, and I wanna get all these rows to be written into my access file. Firstly, I have to ensure that none of these rows can be null. I wrote these codes, yet the problem shows now:
    1. Only when I open the file manually can the file be accessed by my application. (The excel file is in MyDocument folder, can it be the problem of permission that refused me???)
    2. I found quite a lot of copies of application "Excel.exe" running in my processes explorer.(This happens when I tested for quite a time). I cannot quit this application????

    VB Code:
    1. Public Function ValidateExcelFile(strFilePath As String) As Boolean
    2.     Set appExcel = New Excel.Application
    3.     Set wbExcel = appExcel.Workbooks.Open(strFilePath)
    4.     Set wsExcel = wbExcel.Sheets(1)
    5.     Dim lRowNum As Long
    6.     Dim lColNum As Long
    7.     lColNum = wsExcel.UsedRange.Columns.Count
    8.     lRowNum = wsExcel.UsedRange.Rows.Count
    9.     If lColNum <> 2 Then
    10.         ValidateExcelFile = False
    11.         appExcel.Quit
    12.         Set appExcel = Nothing
    13.         Set wbExcel = Nothing
    14.         Set wsExcel = Nothing
    15.         'Exit Function
    16.     Else
    17.         Dim i
    18.  
    19.         For i = 2 To lRowNum
    20.             If wsExcel.Cells(i, 1).Value = "" Then
    21.                 ValidateExcelFile = False
    22.                 Err.Raise "100", , modWizard.GetResString("3004")
    23.                 appExcel.Quit
    24.                 Set appExcel = Nothing
    25.                 Set wbExcel = Nothing
    26.                 Set wsExcel = Nothing
    27.                 Exit Function
    28.             End If
    29.         Next
    30.         ValidateExcelFile = True
    31.         appExcel.Quit
    32.         Set appExcel = Nothing
    33.         Set wbExcel = Nothing
    34.         Set wsExcel = Nothing
    35.     End If
    36.    
    37. End Function


    Hope you guys can help me~~~A help from China )

    Thanks.
    Last edited by si_the_geek; May 22nd, 2006 at 09:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width