I am trying to take data from an excel file an export each row into a new calendar appointment in Outlook.
I am struggling to figure out the Body of the appointment and how I can export the excel data in correctly.
When I copy a cell in column f, it will copy all of the text, when I run the macro, it only pastes the first line.
After that is pasted correctly, I want to include the hyperlinks as a reference.
Currently this is not even displaying, but if/when it does,
I want it to read: TEXT - HYPERLINK (image attached in thread)
Once the macro reaches an empty cell, I want it to drop down to the next row and repeat the process.
Thanks in advance for your help (this has been a week long endeavor, and I am at my wits end...not very talented with VBA yet).
I will send files upon request. I couldn't figure out how to attach the excel file and the images of the appointments.
Below is the Macro.:
Sub CreateIcs()
Dim b As Range
Dim icsTxt As String
Dim fileBasePath As String
fileBasePath = "D:\Users\jmiller\Desktop\test\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each b In Selection.Rows
icsText = icsText + "BEGIN:VCALENDAR" + vbCrLf
icsText = icsText + "PRODID:Commercial Ops" + vbCrLf
icsText = icsText + "VERSION:2.0" + vbCrLf
icsText = icsText + "METHOD:PUBLISH" + vbCrLf
'This creates individual appointments
icsText = icsText + "X-MS-OLK-FORCEINSPECTOROPEN:TRUE" + vbCrLf
icsText = icsText + "BEGIN:VEVENT" + vbCrLf
icsText = icsText + "SUMMARY;LANGUAGE=en-us:" + Cells(b.Row, 5) + vbCrLf
icsText = icsText + "LOCATION:" + Cells(b.Row, 4) + vbCrLf
'This is where I am struggling....all of the text does not copy from the cell in column F.
'It only copies the 1st row of text within that cell (Alt+Enter was used to drop down to the next line within the cell)
icsText = icsText + "X-ALT-DESC;FMTTYPE=text/html:" + Cells(b.Row, 6) + vbCrLf
icsText = icsText + "X-ALT-DESC;FMTTYPE=text/html:" + Cells(b.Row, 10).Text + "-" + "NEED HYPERLINK HERE" + vbCrLf
icsText = icsText + "DTSTART;TZID=""Central Standard Time"":" + Format(Cells(b.Row, 2), "yyyymmddTHHMMss") + vbCrLf
icsText = icsText + "DTEND;TZID=""Central Standard Time"":" + Format(Cells(b.Row, 3), "yyyymmddTHHMMss") + vbCrLf
icsText = icsText + "END:VEVENT" + vbCrLf
icsText = icsText + "END:VCALENDAR" + vbCrLf
'MsgBox (icsText)
Set objFile = objFSO.CreateTextFile(fileBasePath + Cells(b.Row, 5) + ".ics")
objFile.WriteLine icsText
objFile.Close
Next b
MsgBox "Done!"
End Sub
I am struggling to figure out the Body of the appointment and how I can export the excel data in correctly.
When I copy a cell in column f, it will copy all of the text, when I run the macro, it only pastes the first line.
After that is pasted correctly, I want to include the hyperlinks as a reference.
Currently this is not even displaying, but if/when it does,
I want it to read: TEXT - HYPERLINK (image attached in thread)
Once the macro reaches an empty cell, I want it to drop down to the next row and repeat the process.
Thanks in advance for your help (this has been a week long endeavor, and I am at my wits end...not very talented with VBA yet).
I will send files upon request. I couldn't figure out how to attach the excel file and the images of the appointments.
Below is the Macro.:
Sub CreateIcs()
Dim b As Range
Dim icsTxt As String
Dim fileBasePath As String
fileBasePath = "D:\Users\jmiller\Desktop\test\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each b In Selection.Rows
icsText = icsText + "BEGIN:VCALENDAR" + vbCrLf
icsText = icsText + "PRODID:Commercial Ops" + vbCrLf
icsText = icsText + "VERSION:2.0" + vbCrLf
icsText = icsText + "METHOD:PUBLISH" + vbCrLf
'This creates individual appointments
icsText = icsText + "X-MS-OLK-FORCEINSPECTOROPEN:TRUE" + vbCrLf
icsText = icsText + "BEGIN:VEVENT" + vbCrLf
icsText = icsText + "SUMMARY;LANGUAGE=en-us:" + Cells(b.Row, 5) + vbCrLf
icsText = icsText + "LOCATION:" + Cells(b.Row, 4) + vbCrLf
'This is where I am struggling....all of the text does not copy from the cell in column F.
'It only copies the 1st row of text within that cell (Alt+Enter was used to drop down to the next line within the cell)
icsText = icsText + "X-ALT-DESC;FMTTYPE=text/html:" + Cells(b.Row, 6) + vbCrLf
icsText = icsText + "X-ALT-DESC;FMTTYPE=text/html:" + Cells(b.Row, 10).Text + "-" + "NEED HYPERLINK HERE" + vbCrLf
icsText = icsText + "DTSTART;TZID=""Central Standard Time"":" + Format(Cells(b.Row, 2), "yyyymmddTHHMMss") + vbCrLf
icsText = icsText + "DTEND;TZID=""Central Standard Time"":" + Format(Cells(b.Row, 3), "yyyymmddTHHMMss") + vbCrLf
icsText = icsText + "END:VEVENT" + vbCrLf
icsText = icsText + "END:VCALENDAR" + vbCrLf
'MsgBox (icsText)
Set objFile = objFSO.CreateTextFile(fileBasePath + Cells(b.Row, 5) + ".ics")
objFile.WriteLine icsText
objFile.Close
Next b
MsgBox "Done!"
End Sub