+ Reply to Thread
Results 1 to 3 of 3

Workbook Connections and Querytables

  1. #1
    Registered User
    Join Date
    03-29-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Workbook Connections and Querytables

    Hi all

    I am trying to figure out the best way to pull the results of a SQL Server Stored Procedure in to an Excel table.

    The easiest way I have found is to create a Data Connection using the ribbon in Excel, and then refreshing the data using VBA.

    There is one main problem... I would like to send this workbook to a customer, however all they have to do is open the Data Connection properties window and they will have full access to the user credentials for our database (IP address, username and password etc.)

    Would a better approach be to create a connection to the database and then delete it each time the VBA code runs? This way, the customer would not be able to view the Data Connection properties.

    Any sample code for pulling in data from an OLE DB data source and executing a Stored Procedure would be greatly appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Workbook Connections and Querytables

    Yes, you could do it via ADO and paste the recordset returned into Excel. This is the way ive done it in the past. Put some decent error trapping around it though if its going out the the customer. Get some dummy errors with bad credentials to translate the VBA errors into nicer message box ones for the client.

  3. #3
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Workbook Connections and Querytables

    password protect the VBA to.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1