Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save/Load txt files UserForm question Abe[_4_] Excel Programming 1 July 7th 06 12:20 AM
LOAD userform JohnTheTemp Excel Programming 2 September 9th 05 12:45 AM
load/unload userform Fred[_22_] Excel Programming 3 August 22nd 05 04:00 AM
new error when try to load userform izchk shtifman Excel Programming 1 December 30th 03 06:09 PM
Load a Userform Nick Excel Programming 1 September 10th 03 03:24 PM


All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"