ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro - File Save As (https://www.excelbanter.com/excel-programming/300362-macro-file-save.html)

tucopup

Macro - File Save As
 
I'm using the macro below to save a file after clicking a button to
certain cell value. I've moved the start file to a different folder
but the saved version go back to the old one. I can't figure out wh
that is based on the info in the macro.


Sub SaveAs()

Dim a_str1 As String
Dim sname As String

a_str1 = ActiveSheet.Cells(5, 2).Value

sname = Trim(a_str1) + Trim(b_str1) + ".xls"

ActiveWorkbook.SaveAs Filename:=sname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=Fals

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Macro - File Save As
 
I'm not sure what's in a_str1, b_str1, but if you specify the folder you want to
save the workbook to, it might be easier and safer.

ActiveWorkbook.SaveAs Filename:=thisworkbook.path & "\" & sname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

If I understood correctly.

"tucopup <" wrote:

I'm using the macro below to save a file after clicking a button to a
certain cell value. I've moved the start file to a different folder,
but the saved version go back to the old one. I can't figure out why
that is based on the info in the macro.

Sub SaveAs()

Dim a_str1 As String
Dim sname As String

a_str1 = ActiveSheet.Cells(5, 2).Value

sname = Trim(a_str1) + Trim(b_str1) + ".xls"

ActiveWorkbook.SaveAs Filename:=sname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson


tucopup[_2_]

Macro - File Save As
 
Tx Dave. It worked fine. I got that macro off an old post somewher
here

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 02:17 PM.

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