If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Enter new name in save as

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-07-04, 11:33
surfacesys surfacesys is offline
Registered User
 
Join Date: Mar 2004
Location: Greenville, SC
Posts: 271
Enter new name in save as

Sub Save_And_Print()
'
' Save_And_Print Macro
' Prints Proposal then saves it to Completed proposals Folder
'
I have some code written in a macro for a button that saves and prints.
I would like to change the name of the file instead of it, entering it automatically.
Below you see in blue I have the file name highlighted.
How can I change the code to let me enter a new file name?
Actually I would be happy to just stop the code at that window, let me enter my filename.

'
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWorkbook.SaveAs Filename:= _
"C:\WINDOWS\Personal\Completed Proposals\Proposal for XL.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
Application.CommandBars("Forms").Visible = False
End Sub


Thank you,
Michael
__________________
Gotta to do some code
Reply With Quote
  #2 (permalink)  
Old 05-07-04, 11:44
actuary actuary is offline
Registered User
 
Join Date: Mar 2004
Location: Fort Worth, Texas, USA
Posts: 68
'I didn't test this, but it should be close:

dim fname as string, path as string
path = "C:\WINDOWS\Personal\Completed Proposals\"
fname = InputBox("Enter file name")
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWorkbook.SaveAs Filename:= path & fname, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
Application.CommandBars("Forms").Visible = False
End Sub
Reply With Quote
  #3 (permalink)  
Old 05-07-04, 12:31
surfacesys surfacesys is offline
Registered User
 
Join Date: Mar 2004
Location: Greenville, SC
Posts: 271
Even better is there a way to enter the file name according to a cell?

let me explain!

Cell "N8" on the spreadsheet has the actual proposal number that we use to name the file.

The file now automatically saves it to Proposal for XL

Can I have it save it to "Proposal" & Cell N8 somehow?
__________________
Gotta to do some code
Reply With Quote
  #4 (permalink)  
Old 05-07-04, 12:44
actuary actuary is offline
Registered User
 
Join Date: Mar 2004
Location: Fort Worth, Texas, USA
Posts: 68
path = "C:\WINDOWS\Personal\Completed Proposals\"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWorkbook.SaveAs Filename:= path & "Proposal " & _
Str(Application.Range("N8").value), FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
Application.CommandBars("Forms").Visible = False
End Sub

I'd recommend saving before printing though. This allows the filename to automatically print in the footer, if you desire.
Reply With Quote
  #5 (permalink)  
Old 05-07-04, 13:11
surfacesys surfacesys is offline
Registered User
 
Join Date: Mar 2004
Location: Greenville, SC
Posts: 271
Thank You so much.
This sure will make it much easier.

Michael
__________________
Gotta to do some code
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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