突破Excel版本限制写入dbf数据库
如想将Excel内容写入空白的dbf数据库文件中对应列,不限于excel版本
如何通过VB实现?
如何脱离excel版本限制写入dbf数据库.rar
(7.37 KB)
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