Solved how to load picture to submenu ?

VBANewBie :)

Member
Local time
Today, 08:12
Joined
Apr 14, 2021
Messages
88
Hello guys , I have this code
Code:
 Set cbCat = CommandBars.Add(conBarName, msoBarPopup, False, False)
 
  Set cbCatCtrl = cbCat.Controls.Add(msocontrolpopup)
  cbCatCtrl.Caption = "Open Form"
 
  Do While Not rsForms.EOF
      Set cbObjectCtrl = cbCatCtrl.Controls.Add()
      With cbObjectCtrl
      
       .Caption = rsForms!Name
       .Tag = rsForms!Name
       .OnAction = "OpenForm"
'      .Picture = stdole.StdFunctions.LoadPicture("D:\1.bmp")
But it doesn’t work , Error Invalid Picture , I tried .ICO Icons but still the same .
How can I load a picture from my pc and use it as icon instead of faceID method ?
Thanks in Advance
 
2.png
 
If the code lines from your screenshot fail already, there must be something wrong with your image files.
 
Hello guys , I have this code
Code:
 Set cbCat = CommandBars.Add(conBarName, msoBarPopup, False, False)

  Set cbCatCtrl = cbCat.Controls.Add(msocontrolpopup)
  cbCatCtrl.Caption = "Open Form"

  Do While Not rsForms.EOF
      Set cbObjectCtrl = cbCatCtrl.Controls.Add()
      With cbObjectCtrl
     
       .Caption = rsForms!Name
       .Tag = rsForms!Name
       .OnAction = "OpenForm"
'      .Picture = stdole.StdFunctions.LoadPicture("D:\1.bmp")
But it doesn’t work , Error Invalid Picture , I tried .ICO Icons but still the same .
How can I load a picture from my pc and use it as icon instead of faceID method ?
Thanks in Advance
The obvious question is whether there is, in fact, an image file called 1.bmp in the root of the D:\ drive. I'm sure that's the case, but we like to cover all the bases.

The next question, of course, is whether this ever worked in the past, or is this yyour initial attempt to load a picture into a form.

BTW: Here's the code I use for tasks like that:


Private Function LoadFamilyPhoto(ByVal lngEntityID As Long) As String

On Error GoTo errHandler

If lngEntityID > 0 Then
LoadFamilyPhoto = Application.CurrentProject.Path & strImagePath & DLookup("FamilyPhoto", _
"tblEntity", "tblEntity.EntityID = " & Nz(lngEntityID, 0))
Else
LoadFamilyPhoto = Application.CurrentProject.Path & strImagePath & "default.jpg"
End If
Me.imgFamilyPhoto.Picture = LoadFamilyPhoto

Cleanup:

On Error Resume Next

exitProc:

Exit Function

errHandler:
If Err = errConstants.errCantOpenFile Then
LoadFamilyPhoto = Application.CurrentProject.Path & strImagePath & "default.jpg"
Resume
Else
Call GlobalError(IErrNr:=Err.Number, IErrL:=Erl, strErrMod:=Me.Caption, strErrProc:="LoadFamilyPhoto")
End If

Resume Cleanup
Resume

End Function
 
The next question, of course, is whether this ever worked in the past, or is this yyour initial attempt to load a picture into a form.
It does exist.
Yes it is my first attempt to use this method and didn't work yet.
 
here is a 41x41 image
That's the key it worked fine, The problem was the size.. Thank you.
I have a question please can i save this picture into the database so i can use it later without it's full path?
Another one do you have a link for a pictures like your sample?
Thank you so much.
 
you can download a Free image resizer.
you do not need to save the images on the db.
it becomes part of the db when you create the shortcut menu.
 

Users who are viewing this thread

Back
Top Bottom