Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Convert Excel VBA macro to Numbers/Applescript?

Hi,


I have a VBA macro in an excel spreadsheet that outputs a .ICS file from a list of diary events in the spreadsheet. VBA code below to provide background;


'Settings for Excel
Const XlColEvent As Integer = 8 'Column with events
Const XlColLocation As Integer = 9 'Column with locations (tees)
Const XLColDate As Integer = 6 'Column with dates
Const XLColStartTime As Integer = 10 'Column with start times (not used)
Const XLColEndTime As Integer = 11 'Column with end times (not used)
Const XLColNotes As Integer = 7 'Column with notes (section)
Const XLFirstRow As Integer = 2
Dim EventName As String
Dim Location As String
Dim EventDate As String
Dim StartTime As String
Dim EndTime As String
Dim Notes As String
Dim AllDay As Boolean
AllDay = True
Dim SectionName As String
'##############################################################################
SectionName = "Social" 'set this parameter to required section
'##############################################################################
'
'Settings for iCal
Const sLastModified As String = "LAST-MODIFIED:20150101T000000Z"
Const sTimeAdjust As String = "T220000Z" 'Last 8 chars in DTSTART en DTEND
Const IDateStartOffset As Integer = -1 'Depending on your TimeAdjustment ..
Const iDateEndOffset As Integer = 0 ' the Start or End date may need to be 1 day off
'
'Settings for the Outputfile
Dim sOutputFile As String
sOutputFile = "C:\Users\plong\Documents\Personal\PMGC" & SectionName & "2015.ICS"
'
'------------------------------------------------------------------------------- --------------
Dim iRow As Integer
Open sOutputFile For Output As #1
'
'General First Statement
'
Print #1, "BEGIN:VCALENDAR"
Print #1, "VERSION:2.0"
Print #1, "PRODID:http://PMGC.org.uk/ical"
Print #1, "CALSCALE:GREGORIAN"
Print #1, "METHOD:PUBLISH"
With ActiveSheet

For iRow = XLFirstRow To 999
If .Cells(iRow, 1) = "END_OF_FILE" Then
Exit For
End If
EventName = .Cells(iRow, XlColEvent)
Location = .Cells(iRow, XlColLocation)
EventDate = Format(.Cells(iRow, XLColDate), "yyyymmdd")
Notes = .Cells(iRow, XLColNotes)
If EventName <> "0" And Notes = SectionName Then
Print #1, "BEGIN:VEVENT"
Print #1, sLastModified
Print #1, "DTSTAMP:20150101T000000Z"
Print #1, "DTSTART:" & EventDate & ""
Print #1, "SUMMARY:" & EventName & ""

If Location <> "0" Then
Print #1, "LOCATION:" & Location & ""
End If

If Notes <> "0" Then
Print #1, "DESCRIPTION:" & Notes & ""
End If

Print #1, "TRANSP:TRANSPARENT"
Print #1, "END:VEVENT"
End If
Next
End With
Print #1, "END:VCALENDAR"
Close #1
MsgBox "Ready!" & vbCrLf & vbCrLf & iRow - XLFirstRow & " Events haven been entered in " & sOutputFile & vbCrLf _
& "You can now import this file using: Import - Planning - iCal"

End Sub


Question: Is it possible to convert this macro to a Numbers Applescript?


I have a MacBook Pro running Yosemite, I don't have Excel for MacOS and wasn't planning to get it!


Any help would be appreciated..

MacBook Pro with Retina display, OS X Yosemite (10.10.3), iPhone 6, iPad 4

Posted on Jun 29, 2015 4:32 AM

Reply

There are no replies.

Convert Excel VBA macro to Numbers/Applescript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.