Active X in DTS

  • Hi, with regards to working with a excel file that has a password protection on it, can i set the password in my active x code.

    **********************************************************************

    ' Visual Basic ActiveX Script

    '************************************************************************

    ' UpdateExcelWorkbook

    ' Option Explicit

    Function Main()

    Dim Excel_Application

    Dim Excel_WorkBook

    Dim sFilename

    sFilename = DTSGlobalVariables("gv_ExcelFileLocation").Value

    Set Excel_Application = CreateObject("Excel.Application")

    ' Open the workbook specified

    Set Excel_WorkBook = Excel_Application.Workbooks.Open(sFilename)

    Excel_WorkBook.RefreshAll

    Excel_WorkBook.Save

    'Clean Up our Excel Objects

    Excel_WorkBook.Close

    Set Excel_WorkBook = Nothing

    Excel_Application.Quit

    Set Excel_Application = Nothing

    Main = DTSTaskExecResult_Success

    End Function

  •  

    Add the following line just before "Excel_WorkBook.Save"

    Excel_Application.ActiveSheet.Protect "enter password"

  • Sorry i just read what i had written and its confusion, i Already have a password on my excel file and want to refresh it so i neeed to say what the password is to

    open it up refresh it and then save and close.

  • You'll never guess the answer.

     

    Excel_Application.ActiveSheet.Unprotect "enter password"

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply