View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Custom save as pathname and filename



i posted "pseudo code" illustrating
the use of chdrive/chdir before calling the dialog.
which was what you were asking.

if you wrap it in a sub make sfile an argument
(and make the filefilter more flexible.
'in your form..
Sub CallerinUserform()
Call SaveToMYFolder(txtfilename.Text)
End Sub

'in the forms codemodule or a normal module
Sub SaveToMYFolder(sFile$)
Dim sPath$, sFull$
sPath = "c:\"
ChDrive sPath
ChDir sPath
sFull = Application.GetSaveAsFilename(sFile, ",*." & Right$(sFile, 3))
'blah blah

End Sub
--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Aaron Howe wrote :

This works where a contigious name should be given, but the name will
change depending on how the form is filled out... so how do I adapt:

sFull = Application.GetSaveAsFilename(sFile, "CSV files,*.csv")

to make it the pre-defined name from the string?

"keepITcool" wrote:

Aaron, try:

Sub foo()
Dim sPath$, sFile$, sFull$
sPath = "c:\windows\"
sFile = "text.csv"

ChDrive sPath
ChDir sPath
sFull = Application.GetSaveAsFilename(sFile, "CSV files,*.csv")


End Sub




--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam



Aaron Howe wrote :

I have been trying to enter a code into my sheet which will save
the file to a directory on the network using a pre-defined file
name. My filename is a declared string, and is working properly.
I can get as far as:

* Getting the Save As dialogue in the right folder, but with no
filename * Getting the Save As dialogue to show a name, not the
right one, in the last place I saved
* Getting the Save As dialogue to show the completely wrong name
in the right folder.

Assuming I wanted to do this using the GetSaveAsFilename option,
how would I do it? And how would it differ if I wanted an
automatic save where the user didn't have the prompt? The end
result would have to be:

\\server\folder\subfolder\filenamefromstring.xls

Whichever way it was done...!