|
-
January 3rd, 2008, 11:49 AM
#1
excel 2003 - excel 2000 problem
Hello,
My code is working fine on my pc with windows xp home, office 2003.
I tried to install it at another laptop with windows xp home, office 2000. The program works fine, untill i want to run this piece of code :
Code:
Private Sub cmdImport_Click()
Dim intA As Integer
'Dim intB As Integer
Dim intC As Integer
Dim intD As Integer
Dim intE As Integer
'Dim intF As Integer
Dim xlApp As Excel.Application 'excel application
Dim wkBook As Excel.Workbook 'excel workbook
Dim wkSheet As Excel.Worksheet 'excel worksheet
Dim strLevering() As String
Dim liStock As ListItem
CommonDialog1.Filter = "Excel bestanden (*.xls)|*.xls|Alle bestanden|*.*"
CommonDialog1.FilterIndex = 0
CommonDialog1.ShowOpen
Caption = CommonDialog1.Filename
If CommonDialog1.Filename = "" Then Exit Sub
Set xlApp = New Excel.Application
xlApp.Workbooks.Open CommonDialog1.Filename
Set wkBook = xlApp.ActiveWorkbook
Set wkSheet = xlApp.ActiveWorkbook.Sheets(1)
ReDim strLevering(wkSheet.Cells.SpecialCells(xlCellTypeLastCell).Row - 2, 9)
For intA = 0 To wkSheet.Cells.SpecialCells(xlCellTypeLastCell).Row - 2
strLevering(intA, 1) = wkSheet.Cells(intA + 3, 5) 'Produktnaam
strLevering(intA, 2) = wkSheet.Cells(intA + 3, 14) 'Lotnr
strLevering(intA, 3) = wkSheet.Cells(intA + 3, 15) 'Vervaldatum
strLevering(intA, 4) = wkSheet.Cells(intA + 3, 13) 'Aantal
strLevering(intA, 5) = CStr(wkSheet.Cells(intA + 3, 4)) 'Artnr
strLevering(intA, 6) = CStr(wkSheet.Cells(intA + 3, 1)) 'Besteldatum
strLevering(intA, 7) = CStr(wkSheet.Cells(intA + 3, 7)) 'Leveringsdatum
strLevering(intA, 8) = CStr(wkSheet.Cells(intA + 3, 2)) 'Bestelbonnummer
strLevering(intA, 9) = CStr(wkSheet.Cells(intA + 3, 8)) 'Leveringsbonnummer
Next intA
wkBook.Close
xlApp.Quit
Set wkSheet = Nothing
Set wkBook = Nothing
Set xlApp = Nothing
'Loopen door de geneesmiddelen die geleverd zijn en in de stock plaatsen
For intC = 0 To UBound(strLevering)
For intE = 0 To UBound(strproduktlijst)
If CBool(strLevering(intC, 5) = strproduktlijst(intE, 1)) Then
If strproduktlijst(intE, 2) = vbNullString Then
intF = MsgBox("Is " & strLevering(intC, 1) & " een kliniekverpakking?", vbYesNo Or vbInformation)
If intF = vbYes Then
strproduktlijst(intE, 2) = "Ja"
Else
strproduktlijst(intE, 2) = "Nee"
End If
Set adoRs.ActiveConnection = adoCn
With adoRs
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open "Select * from tblProduktlijst where ArtNr = '" & strLevering(intC, 5) & "'"
.Fields("Kliniek") = strproduktlijst(intE, 2)
.Update
End With
adoRs.Close
End If
If strproduktlijst(intE, 3) = vbNullString And strproduktlijst(intE, 2) = "Ja" Then
strproduktlijst(intE, 3) = InputBox("Hoeveel stuks bevat " & strLevering(intC, 1) & "?")
Set adoRs.ActiveConnection = adoCn
With adoRs
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open "Select * from tblProduktlijst where ArtNr = '" & strLevering(intC, 5) & "'"
.Fields("Aantal") = strproduktlijst(intE, 3)
.Update
End With
adoRs.Close
End If
For intD = 0 To strLevering(intC, 4) - 1
Set adoRs.ActiveConnection = adoCn
With adoRs
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open "Select * from tblStock"
.AddNew
.Fields("ArtNr") = strLevering(intC, 5)
.Fields("Produktnaam") = strLevering(intC, 1)
.Fields("Lotnr") = strLevering(intC, 2)
.Fields("Vervaldatum") = strLevering(intC, 3)
.Fields("Kliniek") = strproduktlijst(intE, 2)
If strproduktlijst(intE, 2) = "Ja" Then .Fields("Aantal") = strproduktlijst(intE, 3)
.Fields("Besteldatum") = strLevering(intC, 6)
.Fields("Leveringsdatum") = strLevering(intC, 7)
.Fields("Bestelbonnummer") = strLevering(intC, 8)
.Fields("Leveringsbonnummer") = strLevering(intC, 9)
.Update
End With
adoRs.Close
Next intD
Exit For
End If
Next intE
Next intC
lvStock.ListItems.Clear
Set adoRs.ActiveConnection = adoCn
With adoRs
.LockType = adLockReadOnly
.CursorType = adOpenKeyset
.Open "Select * from tblStock"
End With
Do While Not adoRs.EOF
Set liStock = lvStock.ListItems.Add(, , adoRs!ArtNr & vbNullString)
liStock.SubItems(1) = adoRs!Produktnaam & vbNullString
liStock.SubItems(2) = adoRs!LotNr & vbNullString
liStock.SubItems(3) = adoRs!Vervaldatum & vbNullString
liStock.SubItems(4) = adoRs!Kliniek & vbNullString
liStock.SubItems(5) = adoRs!Aantal & vbNullString
'liStock.Tag = adoRs!StockId
adoRs.MoveNext
Loop
adoRs.Close
End Sub
This code adds drugs with all the needed info(wich i can download from the internet to a excel file) to my Stock table in my database (access).
I have following reference added : Microsoft Excel 11.0 Object Library.
What could be the problem?
Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|