ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving File (https://www.excelbanter.com/excel-programming/357308-saving-file.html)

Greg[_20_]

Saving File
 
Hi all I am wondering how to save a file automaitcally. How do I get excel
to check if there is a folder called "Darts" and if it does not already have
one then it is to create one on the C drive?

Thanks

Greg



Norman Jones

Saving File
 
Hi Greg,

Try something like:


'=============
Public Sub Tester()
Dim WB As Workbook
Const myDir As String = "C:\Darts"
Const newFileName As String = "My File" '<<==== CHANGE

Set WB = ActiveWorkbook '<<==== CHANGE

On Error Resume Next
MkDir myDir
On Error GoTo 0

Application.DisplayAlerts = False
WB.SaveAs Filename:=myDir & "\" & newFileName & ".xls", _
FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True

End Sub
'<<=============


---
Regards,
Norman



"Greg" wrote in message
...
Hi all I am wondering how to save a file automaitcally. How do I get excel
to check if there is a folder called "Darts" and if it does not already
have
one then it is to create one on the C drive?

Thanks

Greg





Greg[_20_]

Saving File
 
Great thanks for that

Greg
"Norman Jones" wrote in message
...
Hi Greg,

Try something like:


'=============
Public Sub Tester()
Dim WB As Workbook
Const myDir As String = "C:\Darts"
Const newFileName As String = "My File" '<<==== CHANGE

Set WB = ActiveWorkbook '<<==== CHANGE

On Error Resume Next
MkDir myDir
On Error GoTo 0

Application.DisplayAlerts = False
WB.SaveAs Filename:=myDir & "\" & newFileName & ".xls", _
FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True

End Sub
'<<=============


---
Regards,
Norman



"Greg" wrote in message
...
Hi all I am wondering how to save a file automaitcally. How do I get

excel
to check if there is a folder called "Darts" and if it does not already
have
one then it is to create one on the C drive?

Thanks

Greg








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

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