I'm trying to get the worksheet name from an excel workbook to pass into a global variable to be used to dynamically change the import task for importing the sheet. I can get the filename and path using the File System Object, but I can't seem to be able to get the first worksheet's name. Here's the code (probably not the best way)
Function Main()
Dim fsoObject, objFolder, objFile, colFiles, strFileName
Set fsoObject = CreateObject("Scripting.FileSystemObject"
Set objFolder = fsoObject.GetFolder("c:\projects\client\source\"
Set colFiles = objFolder.Files
If colFiles.Count > 0 Then
For Each objFile in colFiles
If left(objFile.Name,4) = "prod" Then
strFileName = objFile.Name
End If
Next
End If
DTSGlobalVariables("FileName".value = strFileName
DTSGlobalVariables("FilePath".value = objFolder & "\" & strFileName
DTSGlobalVariables("SheetName".value =
Main = DTSTaskExecResult_Success
Set fsoObject = nothing
Set objFolder = nothing
Set objFile = nothing
Set colFiles = nothing
End Function
Function Main()
Dim fsoObject, objFolder, objFile, colFiles, strFileName
Set fsoObject = CreateObject("Scripting.FileSystemObject"
Set objFolder = fsoObject.GetFolder("c:\projects\client\source\"
Set colFiles = objFolder.Files
If colFiles.Count > 0 Then
For Each objFile in colFiles
If left(objFile.Name,4) = "prod" Then
strFileName = objFile.Name
End If
Next
End If
DTSGlobalVariables("FileName".value = strFileName
DTSGlobalVariables("FilePath".value = objFolder & "\" & strFileName
DTSGlobalVariables("SheetName".value =
Main = DTSTaskExecResult_Success
Set fsoObject = nothing
Set objFolder = nothing
Set objFile = nothing
Set colFiles = nothing
End Function