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

change Source data file

Status
Not open for further replies.

DebbieChapman

Programmer
May 25, 2003
26
0
0
GB
I've found some code on the net that shows me how to change the source data file of a Bulk insert Task, Does anyone know How to change the source data file for an Excel 8.0 connection ?

This is the code I've got

Dim opkg, oBulkInsert
Set oPkg = DTSGlobalVariables.Parent

set oBulkInsert = oPkg.Tasks("DTS_BulkInsertTask_1").CustomerTask

oBulkInsert.DataFile = DTSGlobalVariables("sFileName").Value

Set oBulkInsert = Nothing
Set oPkg = Nothing
 
Here is some code taken from to change the filename of a text connection. It should be easy enough to modify for an Excel connection. Good luck!

Code:
Option Explicit

Function Main()
	Dim oConn, sFilename

	' Filename format - exyymmdd.log
	sFilename = "ex" & Right(Year(Now()), 2)
	If Month(Now()) < 10 Then sFilename = sFilename & &quot;0&quot; & _
	    Month(Now()) Else sFilename = sFilename & Month(Now())
	If Day(Now()) < 10 Then sFilename = sFilename & _
	    &quot;0&quot; & Day(Now()) Else sFilename = sFilename & Day(Now())
	sFilename = DTSGlobalVariables(&quot;LogFilePath&quot;).Value & _
	    sFilename & &quot;.log&quot;

	Set oConn = DTSGlobalVariables.Parent.Connections(&quot;Text File (Source)&quot;)
	oConn.DataSource = sFilename

	Set oConn = Nothing

	Main = DTSTaskExecResult_Success
End Function

--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