ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return Path of selected item from dialogbox (https://www.excelbanter.com/excel-programming/354835-return-path-selected-item-dialogbox.html)

vqthomf

Return Path of selected item from dialogbox
 
Hi I am using xlDialogInsertPicture from a commandbutton and would like to
capture the path of the user selected image, I have sent a lot of time
looking for an answer can someone please help.
TIA
Charles

Dave Peterson

Return Path of selected item from dialogbox
 
Why not just use application.getopenfilename and get the name (and insert the
picture, too).


Kind of...

Option Explicit
Sub testme()
Dim myPictName As Variant
Dim myPict As Picture
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

myPictName _
= Application.GetOpenFilename("Picture files, *.bmp;*.jpg;*.gif")
If myPictName = False Then
MsgBox "try later!"
Exit Sub
End If

With wks
With .Range("a1:B9")
Set myPict = .Parent.Pictures.Insert(myPictName)
myPict.Top = .Top
myPict.Left = .Left
myPict.Width = .Width
myPict.Height = .Height
End With
End With

End Sub


vqthomf wrote:

Hi I am using xlDialogInsertPicture from a commandbutton and would like to
capture the path of the user selected image, I have sent a lot of time
looking for an answer can someone please help.
TIA
Charles


--

Dave Peterson


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com