Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

How to import data into a word document from sql server express 20

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leon Allen - 12 Apr 2007 00:22 GMT
I have a lot of valueable test data (html actually) locked up in a sqlserver
express 2005 database table. I want to access this in word.

I was looking for a word macro, which will connect to the database, and do a
sql select from a colum in a table and display the content in word.

I've looked for a simple example, but found none. Can someone help with a
bit of 'How To' sample code.
Jean-Guy Marcil - 12 Apr 2007 01:15 GMT
Leon Allen was telling us:
Leon Allen nous racontait que :

> I have a lot of valueable test data (html actually) locked up in a
> sqlserver express 2005 database table. I want to access this in word.
[quoted text clipped - 5 lines]
> I've looked for a simple example, but found none. Can someone help
> with a bit of 'How To' sample code.

Here's some pseudo code opening a database under SQL
and opening a recordset.

Dim rs As New ADODB.Recordset

Set cn = New ADODB.Connection

With cn
   .Provider = "SQLOLEDB"
   .Open
"Server=ServerName;Database=DatabaseName;Uid=UserName;Pwd=SecretWord;Trusted_Connection=yes"
End With

rs.Open "SELECT MyField FROM MyTable, cn, adOpenKeyset, adLockReadOnly"

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Peter Jamieson - 13 Apr 2007 11:19 GMT
Another approach is to enable the database toolbar using Tools|Customize and
try inserting your database directly. Although Word initially forces you to
create a .odc (Office Data COnnection) file, you can actually create a
completely empty .odc and put all the connection and query infromationin the
parameters of the DATBASE field.

But make sure you are using Integrated Security, especially if you use the
new SQL client.

Peter Jamieson
>I have a lot of valueable test data (html actually) locked up in a
>sqlserver
[quoted text clipped - 6 lines]
> I've looked for a simple example, but found none. Can someone help with a
> bit of 'How To' sample code.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.