Saving File

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

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
 
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
'<<=============
 
Great thanks for that

Greg
Norman Jones said:
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
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top