Quick question,
Im trying to create a macro inside excel to create a new query.
Upon running this macro, ( wich i created with record macro) al runs smooth.
But transfering to a diffrent user, it prompts a warning and wants a username and password.
No clue how to bypass this, because i thought i had this solved inside the macro...
What did i do wrong???
Im trying to create a macro inside excel to create a new query.
Upon running this macro, ( wich i created with record macro) al runs smooth.
But transfering to a diffrent user, it prompts a warning and wants a username and password.
No clue how to bypass this, because i thought i had this solved inside the macro...
What did i do wrong???
VBA Code:
Sub Macro2()
Dim Xstart, Xend, Xstal As String
Xstart = [start_q]
Xend = [end_q]
Xstal = [stal_q]
ThisWorkbook.Queries.Add Name:="Query1", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Bron = Oracle.Database(""DDIP.WORLD"", [HierarchicalNavigation=true, Query="" select * from MY CODE" & _
" Bron" & _
""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;User ID=USER;Password=PASSWORDX;Data Source=$Workbook$;Location=Query1;Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [Query1]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Query1"
.Refresh BackgroundQuery:=False
End With
End Sub