Forum Discussion
karol polubinski
May 22, 2018Brass Contributor
Control button to create a one time folder, save with date and send work sheet to email
I have tried to write a long code, i ADMIT i AM A BEGINNER. Sub AFolderVBA2() Dim i As Integer For i = 1 To 5 MkDir "C:\Users\kapo\Desktop\Catering\Weekly food Order\" & Range("A" & i) Next i E...
Matt Mickle
May 22, 2018Bronze Contributor
Karol-
Everyone has to start somewhere! I'm happy to assist you. I have made some code comments below to help explain what the code is doing and where you may have potentially gone wrong. Please let me know if you need more assistance. It may help if you can explain in more detail what you are trying to accomplish.
Sub AFolderVBA2()
Dim i As Integer
For i = 1 To 5
'This will iterate through Range A1 to Range A5. and make a new folder directory labeled as such...
MkDir "C:\Users\kapo\Desktop\Catering\Weekly food Order\" & Range("A" & i)
Next i
End Sub
Sub Save()
'Saves this workbook in the following path
ActiveWorkbook.SaveAs Filename:="C:\Users\kapo\Desktop\Catering\Weekly food Order\file00-00-2000\.xlsm", FileFormat _
:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
Sub SendMail()
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
'Supress Errors
On Error Resume Next
'Create email....
With OutlookMail
.To = "" 'You need a recipient...
.CC = ""
.BCC = ""
.Subject = "Weekly Order Note"
.Body = "Good Day to All, Please find Attached order sheet for the week. Please Acknowledge reciept of the attached document, thank you. Best Regards, Camp Boss"
.Attachments.Add Application.ActiveWorkbook.FullName 'This will attach the ActiveWorkbook (This workbook)
.Display 'This displays the email you are about to send.
'You can use this line until the process works perfectly.
'Then you can change it back to using .Send
'.Send
End With
End Sub
karol polubinski
May 23, 2018Brass Contributor
Hi there,
you are my savour.
thank you for your help.
Do you mind if it get back to the subject tomorrow.
I must admit I nearly gave up and binned the whole project.
good before deleting I came back here and saw you response.
thank you very very much
I will be back tomorrow
- Matt MickleMay 23, 2018Bronze Contributor
Karol-
Sure thing. I'll wait for your response tomorrow. Look forward to helping you resolve your issue!