i get an error at the ".Refresh BackgroundQuery:=False" line
this macro used to work fine on my machine, when i transfered to the virtual machine it didn's work and the error i get was this:
my code :
note,, all the paths have been changed to the new ones, so no problem with that
Sub Csv()
Debug.Print ThisWorkbook.Path
Application.DisplayAlerts = False
Workbooks.Add
ActiveWorkbook.Queries.Add Name:="account_Transactions_Other", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(File.Contents(""C:\Users\Alfalakbot4\Desktop\New folder\account_Transactions_Other.txt""),[Delimiter=""#(tab)"", Columns=7, Encoding=1252, QuoteStyle=QuoteStyle.Csv])," & Chr(13) & "" & Chr(10) & " #""Change Type"" = Table.TransformColumnTypes(Source,{{""Column1"", type text}, {""Column2"", type text}, {""Column3"", type text}, {""Column4"", type text}, " & _
"{""Column5"", type text}, {""Column6"", type text}, {""Column7"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Change Type"""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=account_Transactions_Other;Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [account_Transactions_Other]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "account_Transactions_Other"
.Refresh BackgroundQuery:=False
End With
ActiveSheet.ListObjects("account_Transactions_Other").Unlist
Rows("1:4").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Style = "Normal"
Columns("A:A").Select
Selection.NumberFormat = "@"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Range("A1").Select
Workbooks(2).Activate
End Sub