从Word向Access导入 Dim strPath As StringDim iFileNumber As Integer Dim strSusheID As String Dim strScore As String Dim strExtenName As StringDim objWord As Word.Application Dim objDoc As Word.Document iFileNumber = FreeFile rsWeishengdefen.Close rsWeishengdefen.CursorLocation = adUseClient rsWeishengdefen.LockType = adLockBatchOptimistic rsWeishengdefen.Open With CommonDialog1 .Filter = "txt(*.txt)|*.txt|word(*.doc)|*.doc" & "|excel(*.xls)|*.xls|all(*.*)|*.*" .ShowOpen strPath = .FileName End With Screen.MousePointer = vbHourglass '设置鼠标形状为沙漏 Mainfrm.StatusBar1.Panels(2).Text = "正在读入文件,请等待…………" If strPath <> vbNullString Then strExtenName = Right(strPath, 3) If strExtenName = "txt" Then Open strPath For Input As #iFileNumber Do While Not EOF(iFileNumber) Input #iFileNumber, strSusheID, strScore rsWeishengdefen.AddNew rsWeishengdefen.Fields(0) = Text1.Text rsWeishengdefen.Fields(1) = Val(Combo1.Text) rsWeishengdefen.Fields(2) = Val(Combo2.Text) rsWeishengdefen.Fields(3) = Val(Combo3.Text) rsWeishengdefen.Fields(4) = Trim$(strSusheID) rsWeishengdefen.Fields(5) = CSng(Trim$(strScore)) Loop Close #iFileNumber End If If strExtenName = "doc" Then Dim i As Integer Set objWord = New Word.Application Set objDoc = objWord.Documents.Open(strPath)
For i = 1 To objDoc.Words.count Step 3 '步长为3的方法,有n个字段设置步长为n=1 strSusheID = Trim$(objDoc.Words(i).Text) strScore = Trim$(objDoc.Words(i + 1).Text) rsWeishengdefen.AddNew rsWeishengdefen.Fields(0) = Trim$(strSusheID) rsWeishengdefen.Fields(1) = Trim$(strScore) Next i objDoc.Close Set objDoc = Nothing Set objWord = Nothing End If end if这只是一个例子,根据实际情况相应地修改一下
从Word向Access导入(修改一下) Dim strPath As StringDim iFileNumber As Integer Dim strSusheID As String Dim strScore As String Dim strExtenName As StringDim objWord As Word.Application Dim objDoc As Word.Document iFileNumber = FreeFile rsWeishengdefen.Close rsWeishengdefen.CursorLocation = adUseClient rsWeishengdefen.LockType = adLockBatchOptimistic rsWeishengdefen.Open With CommonDialog1 .Filter = "txt(*.txt)|*.txt|word(*.doc)|*.doc" & "|excel(*.xls)|*.xls|all(*.*)|*.*" .ShowOpen strPath = .FileName End With Screen.MousePointer = vbHourglass '设置鼠标形状为沙漏 Mainfrm.StatusBar1.Panels(2).Text = "正在读入文件,请等待…………" If strPath <> vbNullString Then strExtenName = Right(strPath, 3) If strExtenName = "doc" Then Dim i As Integer Set objWord = New Word.Application Set objDoc = objWord.Documents.Open(strPath)
For i = 1 To objDoc.Words.count Step 3 '步长为3的方法,有n个字段设置步长为n=1 strSusheID = Trim$(objDoc.Words(i).Text) strScore = Trim$(objDoc.Words(i + 1).Text) rsWeishengdefen.AddNew rsWeishengdefen.Fields(0) = Trim$(strSusheID) rsWeishengdefen.Fields(1) = Trim$(strScore) Next i objDoc.Close Set objDoc = Nothing Set objWord = Nothing End If end if这只是一个例子,根据实际情况相应地修改一下
1. copy -> paste2. 用报表的形式。
1.我们当初就是找人手工录入的,大概录了两万多道题,找打字社的人录的~~~
2.用VBA控制,具体可以到WORD里录制宏看看!!
Dim strPath As StringDim iFileNumber As Integer
Dim strSusheID As String
Dim strScore As String
Dim strExtenName As StringDim objWord As Word.Application
Dim objDoc As Word.Document iFileNumber = FreeFile
rsWeishengdefen.Close
rsWeishengdefen.CursorLocation = adUseClient
rsWeishengdefen.LockType = adLockBatchOptimistic
rsWeishengdefen.Open
With CommonDialog1
.Filter = "txt(*.txt)|*.txt|word(*.doc)|*.doc" & "|excel(*.xls)|*.xls|all(*.*)|*.*"
.ShowOpen
strPath = .FileName
End With
Screen.MousePointer = vbHourglass '设置鼠标形状为沙漏
Mainfrm.StatusBar1.Panels(2).Text = "正在读入文件,请等待…………"
If strPath <> vbNullString Then
strExtenName = Right(strPath, 3)
If strExtenName = "txt" Then
Open strPath For Input As #iFileNumber
Do While Not EOF(iFileNumber)
Input #iFileNumber, strSusheID, strScore
rsWeishengdefen.AddNew
rsWeishengdefen.Fields(0) = Text1.Text
rsWeishengdefen.Fields(1) = Val(Combo1.Text)
rsWeishengdefen.Fields(2) = Val(Combo2.Text)
rsWeishengdefen.Fields(3) = Val(Combo3.Text)
rsWeishengdefen.Fields(4) = Trim$(strSusheID)
rsWeishengdefen.Fields(5) = CSng(Trim$(strScore))
Loop
Close #iFileNumber
End If
If strExtenName = "doc" Then
Dim i As Integer
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open(strPath)
For i = 1 To objDoc.Words.count Step 3 '步长为3的方法,有n个字段设置步长为n=1
strSusheID = Trim$(objDoc.Words(i).Text)
strScore = Trim$(objDoc.Words(i + 1).Text)
rsWeishengdefen.AddNew
rsWeishengdefen.Fields(0) = Trim$(strSusheID)
rsWeishengdefen.Fields(1) = Trim$(strScore)
Next i
objDoc.Close
Set objDoc = Nothing
Set objWord = Nothing
End If
end if这只是一个例子,根据实际情况相应地修改一下
Dim strPath As StringDim iFileNumber As Integer
Dim strSusheID As String
Dim strScore As String
Dim strExtenName As StringDim objWord As Word.Application
Dim objDoc As Word.Document iFileNumber = FreeFile
rsWeishengdefen.Close
rsWeishengdefen.CursorLocation = adUseClient
rsWeishengdefen.LockType = adLockBatchOptimistic
rsWeishengdefen.Open
With CommonDialog1
.Filter = "txt(*.txt)|*.txt|word(*.doc)|*.doc" & "|excel(*.xls)|*.xls|all(*.*)|*.*"
.ShowOpen
strPath = .FileName
End With
Screen.MousePointer = vbHourglass '设置鼠标形状为沙漏
Mainfrm.StatusBar1.Panels(2).Text = "正在读入文件,请等待…………"
If strPath <> vbNullString Then
strExtenName = Right(strPath, 3)
If strExtenName = "doc" Then
Dim i As Integer
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open(strPath)
For i = 1 To objDoc.Words.count Step 3 '步长为3的方法,有n个字段设置步长为n=1
strSusheID = Trim$(objDoc.Words(i).Text)
strScore = Trim$(objDoc.Words(i + 1).Text)
rsWeishengdefen.AddNew
rsWeishengdefen.Fields(0) = Trim$(strSusheID)
rsWeishengdefen.Fields(1) = Trim$(strScore)
Next i
objDoc.Close
Set objDoc = Nothing
Set objWord = Nothing
End If
end if这只是一个例子,根据实际情况相应地修改一下
我用的是OLE技术,不过我没搞很多的试题实验,等全部完工再去看看!