dbTalk Databases Forums  

Problem with importing Excel Files using loop

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Problem with importing Excel Files using loop in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
KSSG
 
Posts: n/a

Default Problem with importing Excel Files using loop - 04-22-2005 , 01:16 PM






We used the DTS looping procedure to transfer csv files and everything
was fine - but when we used for transfering excel files, it stop on the
first file. We check and we realize on each files, the rename the
worksheet from sheet1 to any other name such as "Zone 1 San Diego
2003_12_08 to "
That's why we have this code below to rename the worksheet back.
But somehow it did not work.
Please help us to configure the proper function to make it work.
Thanks.


Function Main()
'use script to rename all sheets to a common name
dim xlObj
Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open
DTSGlobalVariables("gv_FileFullName").value
xlObj.ActiveWorkbook.Sheets(1).Name = "DataSheet"
xlObj.ActiveWorkbook.Save
xlObj.Quit
Set xlObj = Nothing
Main = DTSTaskExecResult_Success
End Function


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Problem with importing Excel Files using loop - 04-22-2005 , 01:40 PM






If you change the Excel sheet name then you will need to change the SourceObjectName in the datapump task as well as the file name.



--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - SQL Server 2005 Integration Services.
www.Konesans.com


"KSSG" <hariantos (AT) kssg (DOT) com> wrote

Quote:
We used the DTS looping procedure to transfer csv files and everything
was fine - but when we used for transfering excel files, it stop on the
first file. We check and we realize on each files, the rename the
worksheet from sheet1 to any other name such as "Zone 1 San Diego
2003_12_08 to "
That's why we have this code below to rename the worksheet back.
But somehow it did not work.
Please help us to configure the proper function to make it work.
Thanks.


Function Main()
'use script to rename all sheets to a common name
dim xlObj
Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open
DTSGlobalVariables("gv_FileFullName").value
xlObj.ActiveWorkbook.Sheets(1).Name = "DataSheet"
xlObj.ActiveWorkbook.Save
xlObj.Quit
Set xlObj = Nothing
Main = DTSTaskExecResult_Success
End Function




Reply With Quote
  #3  
Old   
Senjaya Harianto
 
Posts: n/a

Default Re: Problem with importing Excel Files using loop - 04-22-2005 , 01:52 PM



The problem is the excel did not allow us to change the worksheet name
even we put the "right" code we think to force them to change the name.
The SourceObjectName is change to DataSheet$ as we wanted
since the Excel worksheet name is still the same- it did not want to go
thru the loop and give us error- do not find the specified file name



*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.