Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation ?:Accepting both Numbers AND specific letters("N","n"," Antonio Excel Discussion (Misc queries) 2 April 22nd 08 05:07 PM
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
"Force" user to save file with specific name jen Excel Programming 1 June 11th 06 01:39 AM
how do I create a macro to "Go To" a location specified in a cell? kim.in.denver Excel Programming 2 June 9th 05 09:15 PM
within a macro how can I suppress the warning pop "A file named xxxx.xls already exists in this location. Do you want to replace it?" Pete McCosh Excel Programming 0 April 2nd 04 04:51 PM


All times are GMT +1. The time now is 03:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"