Storing pictures using relative path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey all, I've been researching this all over the web and can't find too much
on relative path storing.
I'm looking to add a button that pops up a browse for file dialog where what
is selected, is sent to a text box.
I found stuff that will grab the whole path, but none using just the file
name only.
By using just the filename I could use VBA to automatically tell it to
concatenate \inventory\images\[ImageName]

Anyone know how to have a button pass that?
Or is there something better out there?

*The whole purpose for relative path is if I decide to up and move it to a
different PC*

Thanks!!!!
 
This is the procedure I use. The parameter it expects is a reference to the
control you want to return the file name to...

Sub GetFile(Control)
Dim retFile As String, dlg As Variant, s As String
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
.InitialFileName = CodeProject.Path
If .Show = -1 Then s = .SelectedItems(1)
End With
If s <> "" Then
retFile = Right(s, Len(s) - InStrRev(s, "\"))
Control.Value = retFile
End If
End Sub

You'll need to add a reference to MS Office for it to work, and it may not
work if your users are on a PC that has an older version of Office than what
you're using. I think, though, that that's because of the use of the
constant msoFileDialogFilePicker, so if you replace it with the number (3),
it may work for you without the reference.

HTH;

Amy
 
Cool, it looks like it makes sense, I'll try it out tomorrow (Tuesday). In
this part: "I think, though, that that's because of the use of the
constant msoFileDialogFilePicker, so if you replace it with the number (3),
it may work for you without the reference."
Just what do you mean by replace it with the number (3). Can you shed some
light on to what that means?
 
msoFileDialogFilePicker is a constant, defined in the Microsoft Office
library. Its value is 3.

HTH;

Amy
 
Sorry it has taken me so long to get back.
But do you put your code in a module or where?
Thanks,
Jeff
 
Back
Top