none
Script code to set password excel

    Question

  • Dear all, I have a Little troubble with a script on VBS, I wish set a password to Excel files (also PDF DOC and PPT files), I have a code with VBS and I  execute the script and the password protection its ok, but after execute the script the contents of the excel file dissapears, (maybe is creating a new file)

    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    objExcel.DisplayAlerts = FALSE
    
    Set objWorkbook = objExcel.Workbooks.Add
    Set objWorksheet = objWorkbook.Worksheets(1)
    
    objWorksheet.Cells(1, 1).Value = Now
    objWorkbook.SaveAs "EXCELFILE",,"PASSWORD"
    objExcel.Quit
    

    Whyit can be erasing the file information?

    What needed to preserve the contents of the file?, Does it serve me the same code to pdf and doc files?, MANY THANKS!!

    Monday, November 30, 2015 4:00 PM

Answers

All replies