|
我记得我也有一个excel调用的模块.当时是用来计算条码校验位的,后来那个校验位的模块是老头帮忙弄好了,打开excel来计算速度确实很慢:
Function getbc(barcode As String) As String
Dim excelapplication As Object
Dim str As String
str = Application.CurrentProject.path & "\条码计算.xlsx"
Dim oapp As Excel.Application, oappwork As Excel.Workbook, oappwork_Sheet1 As Excel.Worksheet
Set oapp = CreateObject("Excel.Application")
oapp.Visible = False
Set oappwork = oapp.Workbooks.Open(str)
Set oappwork_Sheet1 = oappwork.Worksheets("Sheet1")
oappwork_Sheet1.Cells(1, 1) = barcode
oappwork.Close (True)
oapp.Quit
Set oappwork_Sheet1 = Nothing
Set oappwork = Nothing
Set oapp = Nothing
Set excelapplication = GetObject(str)
getbc = excelapplication.Sheets(1).[a2].Value
Set excelapplication = Nothing
End Function
|
|