Hello again,
I have posted already the problem to delete the code when sending a sheet via email and I have found the solution to the problem.
I tried to do the same when saving the file to specific folder, but i am facing problem.
The code that I am using now is:
Sub SaveFile()
Dim CurrentPath As String
Const PathToSaveTo As String = "C:\Documents and Settings\All Users\Documents\"
'Store the current path
CurrentPath = CurDir
''Change the path to the one we want
'ChDrive "C"
'ChDir PathToSaveTo
''or perhaps...
SetCurrentDirectory PathToSaveTo '"\\SomeServer\Some Path"
'test to see if the folder is already saved in the correct folder
With ThisWorkbook
If .Path <> PathToSaveTo Then
.SaveAs FileName:=PathToSaveTo & .Name
Else
'file is already saved in folder therefore just save it
.Save
End If
End With
''Change the path back
'ChDrive CurrentPath
SetCurrentDirectory CurrentPath
End Sub
Can I add somewhere in this code the lines that will delete the code form the file?
Destwb.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule.DeleteLines 1, _
Destwb.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule.CountOfLines
Bookmarks