Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
A save/load txt UserForm
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
A save/load txt UserForm
Thanks.
Looks like it'll work great. -Abe Die_Another_Day wrote: 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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
A save/load txt UserForm
Look at GetOpenFilename in VBA Help.
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Abe" wrote in message oups.com... 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Save/Load txt files UserForm question | Excel Programming | |||
LOAD userform | Excel Programming | |||
load/unload userform | Excel Programming | |||
new error when try to load userform | Excel Programming | |||
Load a Userform | Excel Programming |