|
4#
楼主 |
发表于 2011-2-21 11:40:13
|
只看该作者
结帖:学的那英文网站的,建立如下模块代码,在连接SQL服务器成功后调用本代码。特别谢谢朱老师的实例。
Public Function LoadRibbons()
'Load ribbons into the database
On Error GoTo Error1
Dim strSQL As String
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
strSQL = "SELECT * FROM UsysRibbon "
' [Ribbons] has to be replaced by your table name.
'cnn.Open CurrentProject.Connection
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do Until rst.EOF
'Debug.Print rst("RibbonName").Value
'Debug.Print rst("RibbonXml").Value
Application.LoadCustomUI _
rst("RibbonName").Value, rst("RibbonXml").Value
' strRibbon = rst("RibbonName").Value
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
'cnn.Close
Set cnn = Nothing
Error1_Exit:
On Error Resume Next
rst.Close
Set rst = Nothing
' Set db = Nothing
Exit Function
Error1:
Select Case err
Case 32609
' Ribbon already loaded
Case Else
MsgBox "Error: " & err.Number & vbCrLf & _
err.Description, vbCritical, _
"Error", err.HelpFile, err.HelpContext
End Select
Resume Error1_Exit
End Function
file:///C:/Documents%20and%20Settings/杨中群/Application%20Data/Tencent/Users/446268928/QQ/WinTemp/RichOle/%]{8AHLY7HV_]]X`%MBJJE0.jpg
|
|