View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Save it giving as a name the content of a cell

You need to first add a command button to worksheet. follow these directions

1) Open Control Toolbox toolbar: View Menu - Toolbars - Control Toolbox.
Trianle on toolbar toggle between enter/exit Design Mode. Placing mouse over
Triangle should say exit (which means you are in design mode). If it says
Enter, then press button once.
2) Press Command Button, then click on worksheet to add button. Resize
button if necessary.
3) Press Properties on Toolbar. Change Caption to "Save It".
4) Right Click Command button and select View Code.
5) Paste this code into VBA window between two lines that already exists.

filesavename = Application.GetSaveAsFilename( _
InitialFileName:= _
"c:\temp\" & Range("A1") & ".xls", _
FileFilter:= _
"Excel Files (*.xls), *.xls")
ThisWorkbook.SaveAs filesavename

6) Close VBA window
7) On toolbar, Press Triangle (exit design mode).
8) Button should now work.

I wonder who could help me with this. I've got a spreadsheet called €śBlank
Form€ť saved as a template. I want to attach a macro to a button in the
spreadsheet called €śSave It€ť in a way that when someone clicks on it the Save
window opens up and in File name it writes the content of cell A1. The
content of the cell will be something like €śNAT-NU-1-001€ť and it should ask
where to save it but give the name of the file by default.

Thank you