I don't know if this is possible to do or not........I know I could
do using a form, anyways what I am trying to do is to allow the user to use
the file open and save dialog boxes. However, I don't want to be able to
save the data file in any other location on their harddrive other than the
one I specify. This is very important for the client to have this
functionality........if anyone knows how to do this, then let me know...:)
Scenario
All data files are stored in c:\client\data and the user should not be able
to store their data in any other location other than this one. They
shouldn't be allowed to create directories off this directory either from
within the application.
I want to use the Excel built-in open and save file dialogs......and disable
any of the options on these dialogs that would allow the user to change the
location of where the data file is saved...:)
Thanks in advance for yer help....:)
JohnD
The Application.GetOpenFilename and Application.GetSaveAsFilename
methods allow you to show the standard Excel Open and Save dialogs, but
instead of actually doing anything they simply return you the path and
filename the user selected (if they click OK) or False (if they click
Cancel). It will then be up to you to actually open or save the file based
on whether what you get back is valid. Here's an example:
Sub SaveFile()
Dim szInitName As String
Dim szFilter As String
Dim szTitle As String
Dim szFile As String
Dim szPath As String
szInitName = "InitialName.xls"
szFilter = "Excel Workbooks (*.xls),*.xls"
szTitle = "Please Select a Filename to Save Under"
szPath = "c:\client\data"
szFile = Application.GetSaveAsFilename(szInitName, szFilter, , szTitle)
If szFile <> "False" Then
If InStr(LCase(szFile), szPath) = 0 Then
MsgBox "Bad Filename!", vbCritical, "Error"
Else
''' Do your processing here.
End If
End If
End Sub
--
Rob Bovey - The Baarns Consulting Group
http://www.baarns.com
John Daly wrote in message ...
How about something like this:
1.chDir to "C:/client/data"
2. use GetOpenFilename to get the "save as" string
3. check for "C:/client/data" in the "save as" string : if not present,
msgbox("Please use the directory C:/client/data") then loop back to step 1.
Remember to allow the loop to escape if the user presses cancel.
Tim.