+ Reply to Thread
Results 1 to 2 of 2

need help using send keys

  1. #1
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500

    need help using send keys

    Hi,

    I have a workbook which is password protected which I would like to 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 the word stewart which is the password in my code any where that I have the cursor. Is there a way I could stop this?

  2. #2
    Tom Ogilvy
    Guest

    RE: need help using send keys

    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.

    --
    Regards,
    Tom Ogilvy


    "funkymonkUK" wrote:

    >
    > Hi,
    >
    > I have a workbook which is password protected which I would like to
    > 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 the
    > word stewart which is the password in my code any where that I have the
    > cursor. Is there a way I could stop this?
    >
    >
    > --
    > funkymonkUK
    > ------------------------------------------------------------------------
    > funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
    > View this thread: http://www.excelforum.com/showthread...hreadid=552580
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1