save file via Marco
Tom,
Here is one way
Sub CheckFolder()
Dim vFilename
Dim sFolder
Dim fso
sFolder = "C:\NewDir"
If Not FolderExists(sFolder) Then
MkDir sFolder
End If
vFilename = sFolder & "\" & _
"Export Q 1.0 " & _
Worksheets("Export").Range("A2").Value & ".xls"
ActiveWorkbook.SaveAs Filename:=vFilename, _
FileFormat:= _
xlNormal, Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWindow.Close
End Sub
'-----------------------------------------------------------------
Function FolderExists(Folder) As Boolean
'-----------------------------------------------------------------
Dim sFolder As String
On Error Resume Next
sFolder = Dir(Folder, vbDirectory)
If sFolder < "" Then
If (GetAttr(sFolder) And vbDirectory) = vbDirectory Then
FolderExists = True
End If
End If
End Function
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Tom" wrote in message
...
Hi,
I'm using this macro :
Dim vFilename
vFilename = "Export Q 1.0 " & Worksheets
("Export").Range("A2").Value & ".xls"
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:=vFilename,
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWindow.Close
The problem is that the file is not allways saved on c:
Is it possible to save it allways on C:
Or is it even possible to save in on C:\XXX.
Can be checked If c:\XXX exists ? If not create C:\XXX ?
Thanks !
Tom
|