View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default How to save a file

Hi Hon123456,

Try something like:

'================
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim res As String
Const sPath As String = "C:\aFolder\" '<<=== CHANGE

Set WB = ActiveWorkbook '<<=== CHANGE

res = InputBox("Please enter new file name")

WB.SaveAs Filename:=sPath & res, _
FileFormat:=xlWorkbookNormal

End Sub
'<<================

Note that no error checking has been included.


---
Regards,
Norman


"hon123456" wrote in message
ps.com...
Dear all,

I want to place a button in a worksheet, which will ask for
a filename, after the user input the
filename, I want to save the file to a particular directory, how can I
do that? I do not want to use the common dialog box. I want to use an
inputbox which ask for filename, after the user input filename in
inputbox, then I will immdeately save the file, what is the function to
set the saving directory and what is the function to save(write) a
excel file?

Thanks.