VBA macro need to be converted to Google Scripts PLEASE HELP!!!

remejiah

New Member
Joined
Jul 13, 2016
Messages
18
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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top