Макрос на Visual Basic for Application для загрузки данных из Excel в Access
Sub LoadExcel()
Dim name As
String
Dim oborot, pribil As Double
Dim Exc As Object
Set Exc = CreateObject("Excel.Application")
Exc.Visible
= False
Exc.DisplayAlerts = False
Exc.Workbooks.Open "G:\TOP400.xls"
For i = 2 To 401 Step 1
name = Trim(Exc.Worksheets("TOP400").Cells(i, 2).Value)
oborot
= CDbl(Exc.Worksheets("TOP400").Cells(i, 4).Value)
pribil
= CDbl(Exc.Worksheets("TOP400").Cells(i, 6).Value)
sql = "INSERT
INTO Corporation (Corporation_name,Country,Type1,Оборот,Прибыль) VALUES
('" + Trim(name) + "','1','12','" + Trim(CStr(oborot)) + "','" + Trim(CStr(pribil)) + "')"
CurrentDb.Execute sql ' вставляем индикатор
Next i
Exc.Quit
Set Exc = Nothing
End Sub