close

Hi Preacher Man,

Please don't cross-post to multiple newsgroups.

This bit of code sets a connection to Northwind on my local server

Sub UpdatePivot()
Dim pvt As PivotTable
Dim pCache As PivotCache
Dim sSQL, sServer, sUser As String

Set pvt = PivotTables(1)
Set pCache = pvt.PivotCache

' write a SQL query
sSQL = quot;SELECT Orders.* FROM master.dbo.Orders Ordersquot;

' select the server and login
sServer = quot;EDSLAPquot;
sUser = quot;saquot; ' log in as sa, will ask for pwd

pCache.CommandText = sSQL

pCache.Connection = quot;ODBC; DRIVER=SQL SERVER;quot; _
amp; quot;SERVER=quot; amp; sServer amp; quot;;quot; _
amp; quot;UID=quot; amp; sUser amp; quot;;quot; _
amp; quot;APP=Microsoft Office 2003quot;

pCache.Refresh

End Sub

Ed Ferrero
Microsoft Excel MVP
www.edferrero.com

gt; Is this possible. To explain myself, here is my situation. I created an
gt; Excel Spreadsheet that uses an ODBC link to a SQL database. In order for
gt; anyone to use this file on their PC, that same ODBC link must be setup.
gt; Is
gt; their some code I can use within a Select Statement that will allow me to
gt; bypass having to create an ODBC on everyone's PC?
gt;
gt; Thanks.
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()