Hi all I have the below code. It is using MS Access data source , I want to change it to csv file as the file will now be csv rather than MS Access. Can you help me change the line of codes to do the trick. I am expecting the underline lines of code but will appreciate any change.
Thanks in advance to all.
Sub Report() Dim WS As Woksheet
Dim WB As Workbook
Set WB = ThisWorkbook
Set WS = WB.Worksheets("Report")
Application.ScreenUpdating = False
WS.Cells.Clear
Workbooks(ThisWorkbook.Name).Connections.Add2 _
"DbFile", "", Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=C:\Users\C033732\Desktop\Report Templates\Dennis Report" _
, _
"DbFile.accdb;Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path=" _
, _
""""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;" _
, _
"Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt" _
, _
" Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;" _
, _
"Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Byp" _
, "*** ChoiceField Validation=False"), "SourceTable", 3
Dim PC As PivotCache
Dim PT As PivotTable
Dim PTn As PivotTable
WS.Activate
'Delete Prior PivotTable
Set PC = WB.PivotCaches.Create(SourceType:=xlExternal, SourceData:=WB.Connections("DbFile"), Version:=6)
Set PT = PC.CreatePivotTable(TableDestination:="Report!R3C1", TableName:="xLabor", DefaultVersion:=6)
Thanks in advance to all.
Sub Report() Dim WS As Woksheet
Dim WB As Workbook
Set WB = ThisWorkbook
Set WS = WB.Worksheets("Report")
Application.ScreenUpdating = False
WS.Cells.Clear
Workbooks(ThisWorkbook.Name).Connections.Add2 _
"DbFile", "", Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=C:\Users\C033732\Desktop\Report Templates\Dennis Report" _
, _
"DbFile.accdb;Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path=" _
, _
""""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;" _
, _
"Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt" _
, _
" Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;" _
, _
"Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Byp" _
, "*** ChoiceField Validation=False"), "SourceTable", 3
Dim PC As PivotCache
Dim PT As PivotTable
Dim PTn As PivotTable
WS.Activate
'Delete Prior PivotTable
Set PC = WB.PivotCaches.Create(SourceType:=xlExternal, SourceData:=WB.Connections("DbFile"), Version:=6)
Set PT = PC.CreatePivotTable(TableDestination:="Report!R3C1", TableName:="xLabor", DefaultVersion:=6)