LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Custom save as pathname and filename

This may be a little late for your purposes, but this worked for me.

Sub ResAlertForm_SaveAs()
Application.ScreenUpdating = False

On Error GoTo ErrRoutine
Dim MyPath As String
Dim MyDirName As String
Dim SuggName As String
Dim NewDir As String

' customize this row with the path you want to scan
MyPath = "Z:\Agent Forms\Reservation Alert Forms"
MyDirName = Sheets("Reservation Alert Form").Range("H8") 'name of resort

' the next intruction tries to create a new directory.
' If a directory by the specified name already exists, it
' returns an error, number 75. This error is managed by
' the ErrRoutine block.
MkDir (MyPath & "\" & MyDirName)
NewDir = MyPath & "\" & MyDirName

' creates the file name (dd_mm_yyyy_xxxxxxRCNA.xls)
SuggName = Sheets("Reservation Alert Form").Range("D13") _
& ("_") & Sheets("Reservation Alert Form").Range("F13") _
& ("_") & Sheets("Reservation Alert Form").Range("H13") _
& ("_") & Sheets("Reservation Alert Form").Range("D21") _
& ".XLS"

'Changes Current Directory
ChDrive NewDir
ChDir NewDir

' Saves the copy of the form to the
ActiveWorkbook.SaveAs (NewDir & "\" & SuggName)
ExitRoutine:

Call ResAlertForm_Email
Exit Sub
ErrRoutine:
' run-time error 75 - Path/File Access error
If Err.Number = 75 Then
Resume Next
Else
MsgBox Err.Number & ": " & Err.Description
Exit Sub
End If

End Sub

"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...!

 
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
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
save as different filename Tom Excel Programming 3 May 4th 05 03:41 AM
Save Filename Peter Excel Programming 3 February 4th 05 01:15 PM
save as filename Geo Siggy[_14_] Excel Programming 3 April 6th 04 01:26 PM
LoadPicture Pathname or no Pathname Philipp Schramek Excel Programming 1 July 8th 03 03:30 PM


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

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

About Us

"It's about Microsoft Excel"