Solved

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

Posted on 2009-05-06
1
250 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
ID: 24315387
>>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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

792 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