Hi Guys,
i am using this code to create listobject with oledb connection from external web source.
It is working nice.
This is result.
The issue is that i had to change all the names from camel cases to upper cases for power queries names, so in this case it is "HanaTable" and should be replaced to "HANATable".
After replacing i am getting error:
I renamed this manually (i suppose in VBa it is not possible).
But why it is no more connected with workbook?
steps to reproduce:
1) renamte "hanaTable" to "HANAtable".
2) Try to refresh power query.
3) See the error.
I need code to do this or workaround...
Please help,
link to example workbook:
Best,
Jacek
i am using this code to create listobject with oledb connection from external web source.
It is working nice.
VBA Code:
Sub test()
QName = "HanaTable"
MFormula = ActiveSheet.[E1].Value
ThisWorkbook.Queries.Add Name:="PQ" & QName, Formula:=MFormula
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=" & "PQ" & QName & ";Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM " & "PQ" & QName)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = QName
.Refresh BackgroundQuery:=False
End With
With ActiveSheet.ListObjects(1).QueryTable
' .WorkbookConnection.Name = "PQ" & QName
.WorkbookConnection.RefreshWithRefreshAll = False
.WorkbookConnection.OLEDBConnection.BackgroundQuery = False
End With
End Sub
This is result.
The issue is that i had to change all the names from camel cases to upper cases for power queries names, so in this case it is "HanaTable" and should be replaced to "HANATable".
After replacing i am getting error:
I renamed this manually (i suppose in VBa it is not possible).
But why it is no more connected with workbook?
steps to reproduce:
1) renamte "hanaTable" to "HANAtable".
2) Try to refresh power query.
3) See the error.
I need code to do this or workaround...
Please help,
link to example workbook:
ExampleConnectionsv5.xlsm
drive.google.com
Best,
Jacek