title: How to disable the "Select Data source window in VBA"
body: <p>I have a excel file with macro-enabled that is used to upload the data from excel into a database. There's a button in excel to run this code. When I run the code, it has a window pop-up "Select Data Source". Does anyone how to prevent this from popping up.</p>
  
  <p>Thank You</p>
  
  <p>Sadly as a beginner I cannot provide the picture so I will explain.</p>
  
  <p>When the button is clicked. A window is opened named "Select Data Source" with three options dBASE Files, Excel Files, MS Access Database. I need to select one of them and continue on. For me it's excel so I click this  and press okay. Then it has the option of allowing me to select the workbook.  Is there a way to pre-do this before so that I don't see this window.</p>
  
  <p>The code is shown Below, which gives this problem.</p>
  
  <pre><code>Sub Collect_campaigns()
  Dim qryCampaigns As String
  Application.ScreenUpdating = False
  qryCampaigns = "SELECT * FROM test.tbl_test;"
  Worksheets("Campaigns").Visible = True
  
  Sheets("Campaigns").Select
  Range("A:F").Select
  Selection.Clear
  Range("A1").Select
  With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
      "ODBC;DSN=TEST_DATASOURCE;", Destination:=Range("$A$1")).QueryTable
  .CommandText = qryCampaigns
  .Refresh BackgroundQuery:=False
   End With
  </code></pre>