VBA to take a CSV Outlook Attachment and Save it as XLSX

  • 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.


  • Have to look at the below line.


    Code
    1. replace this
    2. myWB.SaveAs saveFolder & DateFormat & " " & objAtt.FileName & "x", FileFormat:=51
    3. with
    4. myWB.SaveAs saveFolder & DateFormat & " " & objAtt.FileName & ".xlsx", FileFormat:=51

    While that was a mistake on my part, it still does not solve the overall issue. A File explorer dialog box pops up for less than a second and disappears when running the rule.

  • Cs you may want to throughly check ur code.


    Code
    1. myFileName = mySaveFolder & "Inventory Balance" & " " & DateFormat

    with

    Code
    1. myFileName = mySaveFolder & "\Inventory Balance" & " " & DateFormat

    This becomes a redundant slash if my save folder path ends with / ? It doesn't in my code example but the actual path does.

  • please share the screen shot of the error

    That's what is throwing me, it doesn't give an error. When run it pops up a file explorer window for half a second and closes. Even when told to stop on all errors it runs the same. So as much as I would like to in order to help you out with what's going on, there's just no screenshot to take.


    If you would like I can screenshot the code from the actual window and then do my best to nab the file explorer window but it's not likely.