Create query from Oracle Databese without prompt

Trick0909

New Member
Joined
Dec 15, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
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???

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
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,223,262
Messages
6,171,080
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top