Hi all,
I have a number of password protected Word templates that I need to open from within Excel using VBA.
I use the following code to open the files but can not figure out how to send a password across?
Any help would be appreciated.
AJW
Code
Sub wordtemp()
On Error GoTo ErrorHandler
Dim wdApp As Word.Application
Dim MyDoc As Word.Document
Dim mywdRange As Word.Range
Set wdApp = New Word.Application
With wdApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set MyDoc = wdApp.Documents.Add("C:\Business\Force\TEMPLATES\New Templates\CONTRACT VARIATION .dot")
Set mywdRange = MyDoc.Words(1)
Exit Sub
ErrorHandler:
Set wdApp = Nothing
Set MyDoc = Nothing
Set mywdRange = Nothing
MsgBox ("Could not locate document")
End Sub
Display More
Edit: WillR - added code tags... please use them when posting code. Thanks