我有以下 旧 VB6工作代码在Outlook中添加自定义按钮(在新工具栏中)
Dim oApp As Object
Dim objIns As Object
Dim objCBar As Object
Dim lpobjButton As Object
Set oApp = CreateObject("Outlook.Application")
Set objIns = oApp.ActiveExplorer
Set objCBar = objIns.CommandBars.Add(barra)
Set lpobjButton = objCBar.Controls.Add()
With lpobjButton
.Caption = "myLabel"
.HyperlinkType = 1
.ToolTipText = "myLink"
End With
我正在尝试向按钮添加图像,但是当我执行以下
时Dim oApp As Object
Dim objIns As Object
Dim objCBar As Object
Dim lpobjButton As Object
Dim picPicture As IPictureDisp
Set oApp = CreateObject("Outlook.Application")
Set objIns = oApp.ActiveExplorer
Set objCBar = objIns.CommandBars.Add(barra)
Set picPicture = stdole.StdFunctions.LoadPicture(App.Path & "\myimage.bmp")
Set lpobjButton = objCBar.Controls.Add()
With lpobjButton
.Caption = "myLabel"
.Picture = picPicture '<--- runtime error 8000ffff here
.HyperlinkType = 1
.ToolTipText = "myLink"
End With
我收到运行时错误
(8000ffff) when assigning picPicture to .Picture.
myimage.bmp is a 16x16 image (256 color)
OL 2007
任何想法?
感谢
答案 0 :(得分:1)
更改您的代码以使用从剪贴板复制图片的PasteFace方法。当然,这意味着你必须先将你的照片放在剪贴板上。
With lpobjButton
.Caption = "myLabel"
Clipboard.Clear
Clipboard.SetData picPicture, vbCFBitmap
.PasteFace
''.Picture = picPicture '<--- runtime error 8000ffff here
.HyperlinkType = 1
.ToolTipText = "myLink"
End With