Hi, So each day I get emails with attachments in csv form but I need them to be in xlsx form when saved. So what I am trying to do is use a rule within outlook that will take the CSV file, convert it, and save it as a xlsx in another folder. Here is what I have so far but it doesn't seem to function properly.
Public Sub SaveCSVtoExcel(itm As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim mySaveFolder As String
Dim objSelection As Outlook.Selection
Dim myFileName As String
Dim objOA As Outlook.Application
Dim myWB As Excel.Workbook
Dim myApp As Excel.Application
Set objOA = CreateObject("Outlook.Application")
Set objSelection = obj.ActiveExplorer.Selection
mySaveFolder = "myfolder/forsaving"
DateFormat = Format(Now, "mmddyy")
For Each oAttachment In itm.Attachments
myFileName = mySaveFolder & "Inventory Balance" & " " & DateFormat
Select Case Right(objAtt, Len(objAtt) - InStrRev(objAtt, "."))
If myApp Is Nothing Then
Set myApp = CreateObject("Excel.Application")
Set myWB = myApp.Workbooks.Open(attchmtName)
myWB.SaveAs saveFolder & DateFormat & " " & objAtt.FileName & ".xlsx", FileFormat:=51
Case "xlsx", "xlsm"
' save in original format
Set myWB = Nothing
Set myApp = Nothing
Set objOA = Nothing
Set objSelection = Nothing
Can anyone let me know what I can do to make this work? Thank you!
Edit: Changed "x" to ".xlsx" (still need advice on fix)