Solved

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

Posted on 2009-05-06
1
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

733 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