VBA code to open protected Word doc with known password isn't working
Hey guys,
This should be pretty simple but for whatever reason my code to open a Word document with a known password isn't working so any help would be appreciated. I'm using the code below from within an Excel file.
Code:
Dim MyWord as object
Dim MyDoc as document
Dim MyPass as string
MyPass = "something"
Set MyWord = createobject("Word.application")
Set MyDoc = MyWord.documents.open(FileName:=whatever, PasswordDocument:=MyPass)
The document opens, but it stays stuck at the window requesting the password and if I type it in manually it works and the rest of the code can continue.
Posted Apr 26, 2023, 9:31 PM UTC · edited
u/InHaUse - Your post was submitted successfully.
Solution Verifiedto close the thread.Failing to follow these steps may result in your post being removed without warning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.