ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro uses "Save As" to a specific location (https://www.excelbanter.com/excel-programming/369893-macro-uses-save-specific-location.html)

Kyle

Macro uses "Save As" to a specific location
 
I have a save as part written in my code and I want it to save to a specific
folder (Lab_Inspection_Data in My Documents). However, the way I have it
written right now does not work. Could someone show me how to write the code
so it saves in the correct folder? Here is my code...

sFilename = Format(Worksheets("Checklist").Range("H4").Value & "_" &
Worksheets("Checklist").Range("B4").Value, "yyyy-mm-dd")
ans = MsgBox("Save file as " & sFilename)
If ans = vbOK Then
ActiveWorkbook.SaveAs "C:\My Documents\Lab_Inspection_Data\" & sFilename
End If

Thanks,
Kyle

Jim Jackson

Macro uses "Save As" to a specific location
 
ActiveWorkbook.SaveAs "C:\My Documents\Lab_Inspection_Data\" & sFilename &
".xls"

If I am reading your code accurately, the required ".xls" is missing.

--
Best wishes,

Jim


"kyle" wrote:

I have a save as part written in my code and I want it to save to a specific
folder (Lab_Inspection_Data in My Documents). However, the way I have it
written right now does not work. Could someone show me how to write the code
so it saves in the correct folder? Here is my code...

sFilename = Format(Worksheets("Checklist").Range("H4").Value & "_" &
Worksheets("Checklist").Range("B4").Value, "yyyy-mm-dd")
ans = MsgBox("Save file as " & sFilename)
If ans = vbOK Then
ActiveWorkbook.SaveAs "C:\My Documents\Lab_Inspection_Data\" & sFilename
End If

Thanks,
Kyle



All times are GMT +1. The time now is 12:05 PM.

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