Hola.
Tengo un DTS que contiene sólo un ActiveX Task con un
pequeño trozo de codigo VB-Script que abre un archivo
Excel, ejecuta una macro dentro de este y luego lo guarda
con otro nombre. Esto se hace de forma recursiva.
El problema es que cuando ejecuto este DTS directamente
(desde el Enterprise Manager, directamente sobre el
servidor) todo funciona ok. Pero cuando desde un cliente
lo ejecuto mediante el comando xp_cmdshell se queda
colgado (no hace nada, y al parecer el cuelgue se produce
al hacer SaveAs).
Alguien me puede ayudar?
El codigo del script es el siguiente:
'**********************************************************
************
' Visual Basic ActiveX Script
'**********************************************************
**************
'// Global variables
Dim oConn
Dim oRS_Data
Dim oRS_Data2
Function Main()
Dim app
Dim book
' open connection
Set oConn = CreateObject("ADODB.Connection")
With oConn
.Provider = "SQLOLEDB.1"
.Properties("Data Source").Value = "DWH-BCN"
.Properties("Initial Catalog").Value = "MSA"
.Properties("Integrated Security").Value = "SSPI"
.Open
End With
' open main recordset
Set oRS_Data = CreateObject("ADODB.Recordset")
oRS_Data.Open "SELECT * FROM [X_SBPRocess_SalesRep] ",
oConn,,2
oConn.Execute "TRUNCATE TABLE log "
set app = CreateObject("Excel.Application")
app.DisplayAlerts = False 'by CESCOLA
While Not oRS_Data.EOF
if oRS_Data(0) <> "" then
Set book = app.workbooks.Open
("X:\Reporting\SalesBudgetTemplateV001.01.xls")
oConn.Execute "INSERT INTO log (logmsg)
VALUES ('" & oRS_Data(0) & "')"
app.Run "SalesBudgetTemplateV001.01.xls!
RefreshData", DTSGlobalVariables("Year").Value, oRS_Data
(0), "DWH-BCN"
book.SaveAs DTSGlobalVariables("Path").Value
& "Template " & trim(oRS_Data(0))
book.Close
Set book = Nothing
end if
oRS_Data.movenext
Wend
app.DisplayAlerts = True 'by CESCOLA
app.Quit
Set app = Nothing
Main = DTSTaskExecResult_Success
End Function
Leer las respuestas