Have a use case. There is a password-encrypted xlsx. The password is for reading the workbook only, and I cannot make any edit or remove the password.
I need an xlsx without password so downstream processing can take the info from there. What I'm thinking is to open a new workbook and save the data there, but it always got stuck at the step where it's trying to open the encrypted workbook. Any idea?
Sub OpenXlsx()
set objExcel = Create.Object("Excel.Application")
path = "c:/myfilepath.xlsx"
newpath = "c:/12myfilepath.xlsx"
' next line Not Working. It's able to open the
' excel, but Excel is still stuck at the screen
' to enter password, and 'excel is waiting for another
' application to complete an ole action'
set wb = objExcel.Workbooks.Open(path, Password = "123")
set wb1 = objExcel.Wookbooks.Add()
wb.Sheets(1).cells.copy
wb1.Sheets(1).cells.paste PasteSpecial:=xlPasteValues
wb1.SaveAs(newpath)
wb.Close
wb1.Close
objExcel.Quit
End Sub
question from:
https://stackoverflow.com/questions/65641466/use-vba-vbs-to-open-xlsx-with-password-and-save-into-a-new-xlsx 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…