I am trying to convert an Excel range to a table using a VBA script run from Outlook.
This worked when run from Excel but not from Outlook:
ListObjects.Add(xlSrcRange, Range("A1:D10"), , xlYes).Name = "myTable"
I tried this next code in Outlook but it failed:
Dim excApp As Excel.Application
Set excApp = GetObject(, "Excel.Application")
excApp.ListObjects.Add(xlSrcRange, Range("A1:D10"), , xlYes).Name = "myTable"
This code threw run-time error '1004' Method 'Range' of object '_Global' failed.
I want to know how to make the code work, but I also want to understand why my code failed so that I can learn from it. I appreciate any suggestions. Thanks!