With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _ "OLEDB;Provider=VFPOLEDB.1;Data Source=C:\DEMO\DEMO.DBC;Mode=Share Deny None;Extended Properties="""";User ID=" _ , _ """"";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN=""""" _ ), Destination:=Range("$A$1")).QueryTable .CommandType = xlCmdTable .CommandText = Array("`employees`") ...etc.
loRange = loExcel.Range("A1") lcConnectionString = [Provider=VFPOLEDB.1;Data Source=C:\DEMO\DEMO.DBC;Mode=Share Deny None;Extended Properties="";User ID="";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN=""] loQueryTable = loExcel.ActiveSheet.ListObjects.Add(0, lcConnectionString, loRange) loQueryTable.CommandType = 3 &&xlCmdTable ...etc.It is failing on ListObjects.Add() call with the following error: