0
我有一個訪問表和字段Word表格中插入行評估數據庫錶行
ID
Field1
Field2
Field3
我也有頭
ID | Field1 | Field2 | Field3
如何導入自動將所有的字表表中的數據從word文件轉換爲評估數據庫?
我有一個訪問表和字段Word表格中插入行評估數據庫錶行
ID
Field1
Field2
Field3
我也有頭
ID | Field1 | Field2 | Field3
如何導入自動將所有的字表表中的數據從word文件轉換爲評估數據庫?
自動導入聽起來不容易,但你可以通過編程來完成。
從訪問,你會做這樣的事情:
dim base as string: base = "INSERT INTO tblname (ID, Field1, Field2, Field3) VALUES ("
dim sql as string
dim ii as long
dim jj as long
dim wrd as object
dim wrdDoc as object
'
docmd.setwarnings false
set wrd = createObject("Word.Application")
wrd.visible = false
set wrdDoc = wrd.Documents.Add("name of word document containing table")
with wrdDoc.Tables(1) 'assuming first table in document
for ii = ? to .Rows.Count 'if the table has column headings, ? = 2, else 1
sql = base
for jj = 1 to 4 '4 = count of columns
sql = sql & iif(jj = 1, "", ",") & CStr(.Cell(ii, jj))
next jj
sql = sql & ")"
docmd.runsql sql
next ii
end with
docmd.setwarnings true
wrd.Quit
set wrddoc = nothing
set wrd = nothing