View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
Default A save/load txt UserForm

abe, use Excel's FileDialogOpen or many other similar file utilities.

simplest one being...
Application.GetOpenFilename

my personal favorite is a home brew...

Option Explicit
Public Type FileProperties
SFile As String
SvLoc As String
Cancelled As Boolean
End Type

Function OpenSesame(ClFilters As Boolean, OTitle As String, _
MultiSelect As Boolean, Optional Fltr As String, Optional FltrName
As String, _
Optional StartFolder As String) As FileProperties

OpenSesame.SFile = Empty
OpenSesame.SvLoc = Empty
OpenSesame.Cancelled = False

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = MultiSelect
If Not IsEmpty(OTitle) Then .Title = OTitle
If Not IsEmpty(StartFolder) Then .InitialFileName = StartFolder
If ClFilters = True Then .Filters.Clear
If Not Fltr = "" Then
If Not FltrName = "" Then
.Filters.Add FltrName, Fltr
Else
.Filters.Add "User Filter", Fltr
End If
.FilterIndex = .Filters.Count
End If
If .Show = True Then
OpenSesame.SFile = .SelectedItems(1)
OpenSesame.SvLoc = .InitialFileName
Else
OpenSesame.Cancelled = True
End If
End With

End Function

HTH

Die_Another_Day
Abe wrote:
I have used Walkenbach's method of saving/loading to text files in his
Power Programming with VBA (2003), but would like to have an
accompanying UserForm that allows the user to search through
directories to both load and save their files--much like the way the
save/load works for any Office product. Anybody have a copy of such
code lying around? Or know a good place to look?