Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default file save as (path and custom name)

Hello,

I would like to write a macro that will save a workbook to a user
provided path and directory with an file name defined via code and
consisting of the original workbook name+textbox1 value+text box 2
value.

Any thoughts?

thanks!

dave

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default file save as (path and custom name)

Found some code in a previous posting. Almost works. How can I use
the ThisWorkbook.Name property and exclude the .xls extension until the
end?

Thanks!

Dave

Sub BtnSaveAs()
Dim Suggest, res, Fname, Hdr, Fs
Application.DisplayAlerts = False
Suggest = RTrim(ThisWorkbook.Name, 4) & "-" &
Sheets("data").Range("A31").Value & "-" &
Sheets("data").Range("A30").Value
Hdr = "Please choose a Destination for the Copy, give it a name then
click save"
GetFname: Fname = Application.GetSaveAsFilename(Suggest,
fileFilter:="Excel File(*.xls), *.xls)", Title:=Hdr)
If Not Fname = False Then
Set Fs = CreateObject("Scripting.FileSystemObject")
If Fs.FileExists(Fname) Or Fs.FileExists(Fname & ".xls") Then
res = MsgBox(Fname & " already exists." _
& " Do you want to replace it?", vbYesNo, "Duplicate")
If res = vbNo Then GoTo GetFname:
End If
ThisWorkbook.SaveAs Fname
End If
Xit:
Application.DisplayAlerts = True
End Sub

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 to Path & Variable file name Otto Moehrbach[_6_] Excel Programming 4 September 2nd 04 10:44 PM
change default file path in Save As dialog box charles[_2_] Excel Programming 3 August 6th 04 03:03 AM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM
Using a variable string in a file save path Ron[_13_] Excel Programming 1 October 16th 03 08:29 PM
Save file path in cell Jim Melchers Excel Programming 1 September 19th 03 11:36 PM


All times are GMT +1. The time now is 03:37 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"