Button to import a picture onto a form

  • Thread starter Thread starter Fiona Sturrock
  • Start date Start date
F

Fiona Sturrock

Guest
I would like to add a button to a form allowing users to import a picture onto the form. Ideally I would like the user to click on the button and a file manager type screen to appear to allow the user to find/browse for the picture they wish to import. Can anyone help?
 
Try this link .

This uses the Windows API to invoke the File/Open dialog.

In the TestIt() function replace with :

Function TestIt()
Dim strFilter As String, strFile As String
Dim lngFlags As Long

strFilter = ahtAddFilterItem(strFilter, "Access Files (*.jpg, *.gif)"
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

strFile = ahtCommonFileOpenSave(InitialDir:="C:\", Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, DialogTitle:="Select file to import")

picControl.Picture = strFile

HTH


GJT
 
Last edited:
Thanks GJT.

There is one bit of code that seems to cause the module to stop
picControl.picture = strfile

My lack of knowledge means that I haven't been able to figure out a fix.

Can you help me again please?
 
This does work - you need to enmsure that you have an image control on your form called 'picControl'. The returned string from ahtCommonFileOpenSave() is the picture path the user has selected .

HTH
 

Users who are viewing this thread

Back
Top Bottom