Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADo, Streams and MS Word - How to question

Status
Not open for further replies.

mpdillon

Programmer
Jan 27, 2004
18
0
0
US
I need to use VBA or VB6 to store paragraphs created in Word to an MS SQL database. I also need to retrieve individual paragraphs and inset them into a temporary Word document for printing before saving the final document to a different table. I performed a search on ADO and Streams and read the 52 replies but still don’t quite have this figured out. I have worked extensively with recordsets and Office automation but never with Streams.
I need to combine stored paragraphs in various orders to create documents for printing. The documents contain subscripts, superscripts and other formatted text. Currently, the customer marks these formatted items with special characters. They expressed an interest in using only MS Word. And with that request, a project was born.

I have created an SQL file, Paragraph with two fields, ID and Document. ID is an integer and Document is an Image type.

To open a paragraph in MS Word, I would think I need to:

Reference ADO and MS Word
Connect to the database
Dimension some sort of Stream, would this be a variable or an Object?
Select the record using the ID field.
Can I use a garden variety recordset to do this select?
rs1.Open "Select * from Paragraph Where ID = 1", dbData, adOpenForwardOnly, adLockReadOnly, adCmdText

Read the Document field into the “Stream”
Code???
Then use the “Stream” to create a temp file or open Word and somehow populate Word with the Streams content.
Code???

Once I had retrieved all my paragraphs and printed the final document, I want to save the final document back to the database into another table.

Do I save the temporary Word document to a file and read that file into a “Stream” and insert it into the database? or is there a better way?
???
???
With rsAdd
!BatchID = 1
!PrintedDocument = ???
end with

Any help( code snippets, other references, web sites, etc.) you can provide would be greatly appreciated.
Once I get it working I will append the final code to this post for future reference.

Thanks,
Pat
 
Donutman,
This is my first post so thanks for the feedback. Which forum would be the most appropriate, Version 5 & 6 Forum ?
 
If it's VB then Visual Basic (Microsoft)--VB.NET. Check out "forum list" at top left box of page.
-Karl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top