save in directory
I am using the following code in the "before save" declaration in the
workbook code. It works great except for one problem. It doesn't save the workbook in the directory I want it to. How do I get it to save in a certain directory/folder? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Application.EnableEvents = False Cancel = True ThisWorkbook.SaveAs Worksheets("DEVIATION REPORT").Range("AM49").Value Application.EnableEvents = True End Sub |
save in directory
Specify the fully qualified path name:
e.g to save Worksheets("DEVIATION REPORT").Range("AM49").Value to the default path application.defaultfilepath & "\" & Worksheets("DEVIATION REPORT").Range("AM49").Value to save to "c:\xx" "c:\xx" & "\" & Worksheets("DEVIATION REPORT").Range("AM49").Value The path must exists or it will fail. "rlm" wrote: I am using the following code in the "before save" declaration in the workbook code. It works great except for one problem. It doesn't save the workbook in the directory I want it to. How do I get it to save in a certain directory/folder? Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Application.EnableEvents = False Cancel = True ThisWorkbook.SaveAs Worksheets("DEVIATION REPORT").Range("AM49").Value Application.EnableEvents = True End Sub |
save in directory
Include the path ThisWorkbook.SaveAs "c:\test " & Worksheets("DEVIATION REPORT").Range("AM49").Value -- mudraker ------------------------------------------------------------------------ mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473 View this thread: http://www.excelforum.com/showthread...hreadid=536682 |
All times are GMT +1. The time now is 12:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com