I have a spreadsheet I developed over several weeks that has a macro built in to export three tabs to csv and email the results. Is there anyone that can help me convert this formula to Google scripts? I am leaving the company in 3 days and they need this done and I wanted to be able to fix this before I leave.
Thanks!!!
Sub csv()
Dim csvFiles(1 To 3) As String, i As Integer
Dim wsName As Variant
Dim OutApp As Object, OutMail As Object
Dim clientName As String
clientName = ThisWorkbook.Worksheets(".").Range("e17").Value & " " & ThisWorkbook.Worksheets(".").Range("e18").Value & " " & ThisWorkbook.Worksheets("CONTENT CALENDAR").Range("h5").Value
i = 0
For Each wsName In Array("FB", "TW", "G+")
i = i + 1
csvFiles(i) = ThisWorkbook.Path & "" & clientName & " " & wsName & ".csv"
ThisWorkbook.Worksheets(wsName).Copy
ActiveWorkbook.SaveAs csvFiles(i), FileFormat:=xlCSV
ActiveWorkbook.Close False
Next
'Email the .csv files
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = ThisWorkbook.Worksheets("CONTENT CALENDAR").Range("B6").Value
.CC = ""
.BCC = ""
.Subject = "CONTENT CALENDAR FOR " & clientName
.Body = "This email contains 3 .csv file attachments."
.Attachments.Add csvFiles(1)
.Attachments.Add csvFiles(2)
.Attachments.Add csvFiles(3)
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
'Delete the .csv files
Kill csvFiles(1)
Kill csvFiles(2)
Kill csvFiles(3)
End Sub
Thanks!!!
Sub csv()
Dim csvFiles(1 To 3) As String, i As Integer
Dim wsName As Variant
Dim OutApp As Object, OutMail As Object
Dim clientName As String
clientName = ThisWorkbook.Worksheets(".").Range("e17").Value & " " & ThisWorkbook.Worksheets(".").Range("e18").Value & " " & ThisWorkbook.Worksheets("CONTENT CALENDAR").Range("h5").Value
i = 0
For Each wsName In Array("FB", "TW", "G+")
i = i + 1
csvFiles(i) = ThisWorkbook.Path & "" & clientName & " " & wsName & ".csv"
ThisWorkbook.Worksheets(wsName).Copy
ActiveWorkbook.SaveAs csvFiles(i), FileFormat:=xlCSV
ActiveWorkbook.Close False
Next
'Email the .csv files
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = ThisWorkbook.Worksheets("CONTENT CALENDAR").Range("B6").Value
.CC = ""
.BCC = ""
.Subject = "CONTENT CALENDAR FOR " & clientName
.Body = "This email contains 3 .csv file attachments."
.Attachments.Add csvFiles(1)
.Attachments.Add csvFiles(2)
.Attachments.Add csvFiles(3)
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
'Delete the .csv files
Kill csvFiles(1)
Kill csvFiles(2)
Kill csvFiles(3)
End Sub