Sub 提取音韵地位() '选中汉字,运行宏即可 Dim zi, a AsString Dim jg AsString zi = Selection.Text
Dim cnn As ADODB.Connection Dim rs As ADODB.Recordset Dim mydata AsString, mySQL AsString mydata = "C:\Program Files\音韵地位\yydw.mdb" Set cnn = New ADODB.Connection
With cnn .Provider = "microsoft.jet.oledb.4.0" .Open mydata EndWith Set rs = New ADODB.Recordset mySQL = "select * from dw where zitou =" & "'" & zi & "'" rs.Open mySQL, cnn, adOpenKeyset, adLockOptimistic If rs.RecordCount <> 0Then For icols = 0To rs.RecordCount - 1 a = rs.Fields("yydw") jg = jg & zi & " " & a & " " & Chr(13) Next icols m = InputBox("共找到" & icols & "个结果。", "音韵地位", jg) Else MsgBox ("未找到“" & zi & "”" & "的音韵地位!") EndIf
rs.Close cnn.Close Set rs = Nothing Set cnn = Nothing EndSub