ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to save a file (https://www.excelbanter.com/excel-programming/363868-how-save-file.html)

hon123456

How to save a file
 
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.


Norman Jones

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.




hon123456

How to save a file
 
Thanks for your help



All times are GMT +1. The time now is 10:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com