Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Password Protected Excel Workbook with VBA from Word 1

Status
Not open for further replies.

ACH381

Technical User
Apr 3, 2002
49
US
Using a VBA command, how do I open an Excel Workbook, that requires a password to open?

I am creating an automated mailmerge project using VBA in Word. I'm using an Excel Workbook as the datasource, but the workbook requires a password to open. I either need to be able to send the password in the "OpenDataSource" method OR open the Excel Workbook, save a copy without a password so mailmerge can access it, run the mailmerge, then delete the copy.
 
The following will open the password-protected workbook:
Code:
Workbooks(NameOfWorkbook).Open Password:="Your Password"

Use the SaveAs method of the Workbook object to save a copy without password protection.


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top