need help using send keys

F

funkymonkUK

Hi,

I have a workbook which is password protected which I would like t
open as read-only.

I managed to get it to work if i used the following

Sub Macro1()

'cancel password which is Stewart

'Dim extractor As String
'extractor = ThisWorkbook.Name

'make file read-only
Application.SendKeys ("%r") '("stewart~")
Workbooks.Open Filename:= _
"C:\Documents and Settings\ME\Desktop\Test.xls"
Sheets("home").Select

' ActiveWindow.Close

End Sub

however when I run the sendkeys function it works however it places th
word stewart which is the password in my code any where that I have th
cursor. Is there a way I could stop this
 
T

Tom Ogilvy

here is one way:

Sub Macro1()

'cancel password which is Stewart

'Dim extractor As String
'extractor = ThisWorkbook.Name

'make file read-only

Workbooks.Open Filename:= _
"C:\Documents and Settings\ME\Desktop\Test.xls", _
Password:="stewart"
Sheets("home").Select

' ActiveWindow.Close

End Sub

I am not sure how that makes the file readonly, however.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top