I downloaded data online but I need to transform the data into a different Unicode because the data are not in English. I recorded a macro to do the data transformation. Below are the macro I recorded. I changed the source and file name to see if I could run the macro when transforming a new data file. However, I got the Run-time error '1004' when running the line ".ListObject.DisplayName = "attorney36" at the very end. I have selected the radio button for "Disable all macros with notification" checked the box for "Trust access to VBA project object model", the error couldn't be solved. Anybody know how to solve it, or know how to write a macro to transform data into different Unicode in VBE? Thank you very much!
Sub Macro()
ActiveWorkbook.Queries.Add Name:="attorney36", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(""C:\Temporary\attorney36.csv""),[Delimiter="","", Columns=6, Encoding=65001, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & " #""Promoted Headers"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(#""Promoted H" & _
"eaders"",{{"""", Int64.Type}, {""id"", Int64.Type}, {""title"", type text}, {""publishdate"", type text}, {""url"", type text}, {""content"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Changed Type"""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=attorney36;Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [attorney36]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
.ListObject.DisplayName = "attorney36"
End With
End Sub