I have to open an excel file every day and refresh the content to get the newest sales-data. I'd like to automate this with windows task scheduling. Since the excel-file is password protected, i read that the best way is to create another excel file with an workbook_open-macro that opens the desired excel-file. The problem though is, that the code i found still prompts the user to enter the password. I can just hit enter and it'll open then, but why is there still the prompt for it? I am using Excel 365, is there some workaround for this or am i doing something wrong?
I tried it with ReadOnly:=False and without, nothing changed. If i set ReadOnly:=True, it works, but then i can't save the file after the changes.
This is the code i'm using:
Sub Workbook_Open()
Application.DisplayAlerts = False
Workbooks.Open Filename:="Path\file.xlsx", Password:="*****", ReadOnly:=False
Application.DisplayAlerts = True
ThisWorkbook.Close SaveChanges:=False
End Sub
Workbooks.Open Filename:="Path\file.xlsx", WriteResPassword:="*****", ReadOnly:=False
– Vincent G