I have tried for weeks to automate my macro.
I have a macro and I want to integrate the following (not to make a new macro):
I want to check if a specific folder exist and if not create 3 folders.
I want to do this regardless of the computer I do it on!
If anyone can help me to crerate thye lines I need to use Environ kindly do so.
I got it to actually make the folders but not to save the files using:
- Code: Select all
Sub Dircheck()
Dim MyFilePath As String
MyFilePath = Environ$("documents") & "\"
Application.ScreenUpdating = True
If Len(Dir("TenisProgram\BackupIndividuales", vbDirectory)) = 0 Then
MkDir "TenisProgram"
MkDir "TenisProgram\BackupIndividuales"
MkDir "TenisProgram\BackupDobles"
End If
The specific macro look like this (some removed):
- Code: Select all
Private Sub CommandBotton1_Click()
Application.ScreenUpdating = False
ActiveWorkbook.save
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "tom@myemailaddress.com"
.CC = ""
.BCC = ""
.Subject = "Full copy Liga Gil"
.Body = "This is a full copy of Liga Gil program end of month - Individuales."
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Dim TestStr As String
TestStr = Format(Now, "dd-mmmm-yyyy_Hh.Nn")
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs FileName:="C:\Documents and Settings\Usuario\Mis documentos\TenisProgram\BackupIndividuales\" & TestStr & "_" & ActiveWorkbook.Name
ActiveWorkbook.save
Application.DisplayAlerts = True
Dim Response As VbMsgBoxResult
Response = MsgBox("Reiniciar PuntuaciĆ³n Individuales?", vbQuestion + vbYesNo)
If Response = vbNo Then Exit Sub
' The rest is removed!!!
End Sub
I hope that there is an VBA expert in here that can give me a hand.
Thank you all for great forum posts.
Kind regards
Tom