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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to do the following wit

Status
Not open for further replies.

megmoo75

Programmer
Jun 14, 2003
40
US
I am trying to do the following within a single DTS package:

1. Export a query (from a stored procedure) into excel
2. Open a word template and mail merge the excel file
3. Save the word document created as a result of the mail merge to a particular directory

I have the export to Excel done. And I have my Word template created and able to merge with the Excel file, but I don't have the automation done to automatically merge it with Word in the DTS package. Is there a way to do this? Can anyone point me in the direction of some threads or websites that might assist me with this?

Thanks in advance.
 
You can use an ActiveX script to access the Word document. I do so to scrub text files prior to import.

Code:
Function Main()
	DIM Word
	wdFindContinue = 1
	wdReplaceAll = 2

	SET Word = CreateObject("Word.Application")
	Word.Application.Documents.Open("c:\File.TXT")

	'--Removes carriage return/line feeds
	NullVar = Word.Selection.Find.Execute("^p",,,,,,"true",wdFindContinue,,"",wdReplaceAll)

	Word.Application.Quit(CBool("true"))
	SET Word = nothing
	Main = DTSTaskExecResult_Success
End Function

There are bound to be methods and properties for Mail Merge. Perhaps a post in one of the VB forums would prove beneficial. Good luck!

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top