突破Excel版本限制写入dbf数据库
如想将Excel内容写入空白的dbf数据库文件中对应列,不限于excel版本
如何通过VB实现?
2021-12-23 10:48
2021-12-23 11:30
2021-12-24 08:26

2021-12-25 16:57
程序代码:Private Sub CommandButton1_Click()
Dim oFox As Object
Set oFox = CreateObject("VisualFoxPro.Application")
oFox.DoCmd "CREATE TABLE C:\temp\test.dbf (f1 I,f2 I,f3 I)"
oFox.DoCmd "INSERT INTO test VALUES (11,12,13)"
oFox.DoCmd "INSERT INTO test VALUES (21,22,23)"
oFox.DoCmd "GO TOP IN 'test'"
oFox.DataToClip "test", , 3
Cells(1, 1).Select
ActiveSheet.Paste
oFox.DoCmd "INSERT INTO test VALUES (" & Cells(2, 1).Value & "," & Cells(2, 2).Value & "," & Cells(2, 3).Value & ")"
oFox.DoCmd "INSERT INTO test VALUES (" & Cells(3, 1).Value & "," & Cells(3, 2).Value & "," & Cells(3, 3).Value & ")"
oFox.DoCmd "GO TOP IN 'test'"
oFox.DataToClip "test", , 3
Cells(5, 1).Select
ActiveSheet.Paste
oFox.DoCmd "USE IN 'test'"
End Sub
2021-12-26 16:42