Solved

Import Excel file - last modified date from specific tab to SQL server

Posted on 2009-05-06
1
247 Views
Last Modified: 2013-11-30
I have the ActiveX script for importing data from excel to SQL with last date modified....
How can i specify the a specific tab form Excel sheet

Function Main()

Dim objFSO, objFile, objFolder

dim strPath

dim dteTemp,strTemp

dim oPackage

dim oConn

 

 

strPath="C:\" 

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(strPath)

 

dteTemp=cdate("1/31/1900")

For Each objFile in objFolder.Files

	

	if cdate(objFile.DateLastModified) > dteTemp then

		dteTemp=objFile.DateLastModified

		strTemp=objFile.Name

	end if

Next

'msgbox strtemp & dtetemp

 

	set oPackage = DTSGlobalVariables.parent

	set oConn = oPackage.connections("Excel")

 

	oConn.datasource = strPath & strTemp

	oPackage.steps("DTSStep_DTSDataPumpTask_1").execute

 

set oPackage = nothing

set oConn = nothing

Set objFolder = Nothing

Set objFSO = Nothing

 

	Main = DTSTaskExecResult_Success

End Function

Open in new window

0
Comment
Question by:mercybthomas74
1 Comment
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
Comment Utility
>>How can i specify the a specific tab form Excel sheet<<
You need to set the SourceObjectName property (for the Data Transformation Task) to the sheet name as in:
oPackage.Task("DTSStep_DTSDataPumpTask_1").SourceObjectName = "Sheet1$"
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now