 |
|
ใช้ Office2003
Error Code:
Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
ในส่วนของ Add Reference
1. Microsoft Excel 11.0 Object Library
2. Microsoft Office 10.0 Object Library
Code (VB.NET)
Public Oxl As Excel.Application
Public Owb As Excel.Workbook
Public OSheet As Excel.Worksheet
Imports Microsoft.Office.Core
Imports System.IO
Call Kill_Process()
Dim File_Name As String = "บาร์โค๊ตรหัส " & TxtWord.Text & TxtStart.Text & "-" & TxtWord.Text & TxtFinish.Text
Oxl = CreateObject("Excel.Application")
Dim A = Application.StartupPath & "\barcode\collection\"
FileCopy(Application.StartupPath & "\barcode\original\BarCode.xls", A & File_Name & ".xls")
Owb = Oxl.Workbooks.Open(A & File_Name & ".xls")//Error Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
Oxl.Visible = True
'-------------------------
Dim BarCode As String : Dim Word As String = Nothing
Dim i, Start, Finish, Count, Colum, Row As Integer
Start = Val(TxtStart.Text) - 1 : Finish = Val(TxtFinish.Text) - 1
Count = Start : Colum = 1 : Row = 0
OSheet = Owb.ActiveSheet
For i = Start To Finish
Count += 1
BarCode = TxtWord.Text & String.Format("{1:000000}", "", Count)
' MsgBox(BarCode)
Row += 1
If Row = 12 Then
Colum += 1 : Row = 1
End If
With OSheet
.Cells(Colum, Row).Value = BarCode
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlContinuous
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlContinuous
End With
Next
Count = 0 : Colum = 0 : Row = 0
Tag : .NET, Ms Access, Ms SQL Server 2005, VB.NET
|
|
 |
 |
 |
 |
Date :
2010-09-16 14:56:01 |
By :
babyprogrammer |
View :
1740 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |