ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Auto Saving (https://www.excelbanter.com/excel-discussion-misc-queries/68406-auto-saving.html)

GarToms

Auto Saving
 
Hi All,

I'v found this code to auto save my worksheet with the name in C1. I want to specify the directory to save it to. Does anyone know what code i can put in it to save to the following directory
L:\Credit Management Team\Gareth Thomas

I also want to change it to just save the 1 sheet in the workbook.

Sub SaveAsCell()
Dim strName As String

On Error GoTo InvalidName
strName = Sheet1.Range("C1")
ActiveWorkbook.SaveAs strName

Exit Sub
InvalidName: MsgBox "The text: " & strName & _
" is not a valid file name.", vbCritical, "Ozgrid.com"
End Sub

Kevin B

Auto Saving
 
When you assign the value of the worksheet name to the variable string name,
concatenate the full path to the file

strName = "L:\Credit Management Team\Gareth Thomas\" & _
Worksheets("Sheet1").Range("C1").Value
--
Kevin Backmann


"GarToms" wrote:


Hi All,

I'v found this code to auto save my worksheet with the name in C1. I
want to specify the file to save it to. Does anyone know what code i
can put in it to save to the following directory
L:\Credit Management Team\Gareth Thomas


Sub SaveAsCell()
Dim strName As String

On Error GoTo InvalidName
strName = Sheet1.Range("C1")
ActiveWorkbook.SaveAs strName

Exit Sub
InvalidName: MsgBox "The text: " & strName & _
" is not a valid file name.", vbCritical, "Ozgrid.com"
End Sub


--
GarToms


GarToms

excelent cheers

Quote:

Originally Posted by Kevin B
When you assign the value of the worksheet name to the variable string name,
concatenate the full path to the file

strName = "L:\Credit Management Team\Gareth Thomas\" & _
Worksheets("Sheet1").Range("C1").Value
--
Kevin Backmann


"GarToms" wrote:


Hi All,

I'v found this code to auto save my worksheet with the name in C1. I
want to specify the file to save it to. Does anyone know what code i
can put in it to save to the following directory
L:\Credit Management Team\Gareth Thomas


Sub SaveAsCell()
Dim strName As String

On Error GoTo InvalidName
strName = Sheet1.Range("C1")
ActiveWorkbook.SaveAs strName

Exit Sub
InvalidName: MsgBox "The text: " & strName & _
" is not a valid file name.", vbCritical, "Ozgrid.com"
End Sub


--
GarToms



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

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