vba MS Access 中的应用程序图标路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/698418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Application Icon path in MS Access
提问by Curtis Inderwiesche
How do you access the Application Icon path in MS Access 2003 programmatically?
如何以编程方式访问 MS Access 2003 中的应用程序图标路径?
采纳答案by DJ.
It's a custom property ("AppIcon") of the database object.
它是数据库对象的自定义属性(“AppIcon”)。
Set dbs = CurrentDb
sAppIconPath = dbs.Properties("AppIcon")
Note - you will get an error if the property doesn;t exist.
注意 - 如果该属性不存在,您将收到错误消息。
This code from the Access Help shows how to create the property:
Access 帮助中的此代码显示了如何创建属性:
Example
例子
The following example shows how to change the AppIcon and AppTitle properties in a Microsoft Access database (.mdb). If the properties haven't already been set or created, you must create them and append them to the Properties collection by using the CreateProperty method.
下面的示例演示如何更改 Microsoft Access 数据库 (.mdb) 中的 AppIcon 和 AppTitle 属性。如果尚未设置或创建属性,则必须使用 CreateProperty 方法创建它们并将它们附加到 Properties 集合中。
Sub cmdAddProp_Click()
Dim intX As Integer
Const DB_Text As Long = 10
intX = AddAppProperty("AppTitle", DB_Text, "My Custom Application")
intX = AddAppProperty("AppIcon", DB_Text, "C:\Windows\Cars.bmp")
CurrentDb.Properties("UseAppIconForFrmRpt") = 1
Application.RefreshTitleBar
End Sub
Function AddAppProperty(strName As String, _
varType As Variant, varValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo AddProp_Err
dbs.Properties(strName) = varValue
AddAppProperty = True
AddProp_Bye:
Exit Function
AddProp_Err:
If Err = conPropNotFoundError Then
Set prp = dbs.CreateProperty(strName, varType, varValue)
dbs.Properties.Append prp
Resume
Else
AddAppProperty = False
Resume AddProp_Bye
End If
End Function