Solved how to load picture to submenu ? (1 Viewer)

VBANewBie :)

Member
Local time
Today, 20:18
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
 

VBANewBie :)

Member
Local time
Today, 20:18
Joined
Apr 14, 2021
Messages
88
2.png
 

sonic8

AWF VIP
Local time
Today, 19:18
Joined
Oct 27, 2015
Messages
998
If the code lines from your screenshot fail already, there must be something wrong with your image files.
 

GPGeorge

Grover Park George
Local time
Today, 11:18
Joined
Nov 25, 2004
Messages
1,776
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
 

VBANewBie :)

Member
Local time
Today, 20:18
Joined
Apr 14, 2021
Messages
88
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:18
Joined
May 7, 2009
Messages
19,169
maybe use 41x41 pixel (or more) image size.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:18
Joined
May 7, 2009
Messages
19,169
here is a 41x41 image.
 

Attachments

  • mini_click.zip
    1.1 KB · Views: 186

VBANewBie :)

Member
Local time
Today, 20:18
Joined
Apr 14, 2021
Messages
88
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:18
Joined
May 7, 2009
Messages
19,169
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

Top Bottom