Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select file dialog

Status
Not open for further replies.

andrew299

Technical User
Nov 18, 2002
140
GB
sorry to ask so many questions but i tend to do a lot and then get stuck.

The latest problem is

I am creating an install file of sorts ( Changing a line of code to point to a file is beyond some people and therefore this is required).

I call a C++ program from within my macro. I have to specify the location of this file in the code. However this will more than likely have to be changed for every new computer that it is put on - fine as long as I am doing it - but I cant be there all the time. To simplify things I have made the location of the code line very clear but to improve m,y program I would like a sort of install file.

This will run once and once only - I think I have sorted this bit but have hit a brick wall when it comes to selecting the file location. I want to open a file dialog or perhaps a user form that will allow the user to browse for the C++ program and record its location which will then be used for the remainder of the programs days. I wanted something sort of like the file save dialog to look at but cant find anything that would suit. So I went to userforms but again how do I bring up a browse function? The easiest way I thought would be a message box but again too much work for people to type in anything. Does anyone have any ideas?

Thanks
Andrew299













 

Sub filefind()


Set fs = Application.FileSearch
With fs
.LookIn = "C:\"
.Filename = "*.exe"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With


End Sub



This works to find the files and file name. But I wnat it to search the directories of c:\ as well.
 
JUST ADD IN

.SearchSubFolders = True

BETWEEN .lookin and .filename
 
Hi andrew299,

Probably this is not a perfect solution for your problem, but have you thought of any standard installer?
I use Inno Setup to transfer my files, it is flexible, customizable and free.

You can download it from:

Combo
 
Thanks Combo
it wasnt quite what I was looking for but has enhanced the program no end.
andrew299
 
For your original question, I think the standard dialog

application.getopenfilename

would do the trick nicely.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top