Help! I need an alternative to "Send Keys"
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Help! I need an alternative to "Send Keys"

  1. #1
    New Member
    Join Date
    Apr 2002
    Location
    Kansas
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I inherited a number of Excel projects and the previous developer open a workbook and delete all but a few sheets... the Send Keys will often not reach the dialog box in time to accomplish the task. I am looking for a way similar to access to set the warning dialog off and then turning it back on after completion... is there a way?

  2. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Before the sendkeys you can make the macro wait, by using the ontime function.
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  3. #3
    New Member
    Join Date
    Apr 2002
    Location
    Kansas
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I didn't want to use send keys... too difficult to guarantee success... but FYI I found the "Application.DisplayAlerts = False" is what I needed. Thanks

  4. #4
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I don't know if you'd be interested, but you don't have to open a worbook to delete sheets from it. This would get rid of the stupid SendKeys command (I have a semi-irrational hatred of that command).

    This example will open a workbook in C:Temp called "Book2.xls" it will then delete sheet2 from that workbook, assuming that sheet exists.


    Public Sub main()

    Dim XL As Excel.Application
    Dim WBK As Excel.Workbook


    On Error GoTo ERR_MAIN
    Set XL = CreateObject("Excel.Application")
    Set WBK = XL.Workbooks.Open("C:TempBook2.xls")

    XL.DisplayAlerts = False
    WBK.Sheets("Sheet2").Delete
    XL.DisplayAlerts = True

    ERR_MAIN:
    WBK.Close savechanges:=True
    Set XL = Nothing

    End Sub


    I hope this is of use.

    EDIT:: Obviously there are too many backslashes in the path definition, but you can remove those. That's a known bug of this message board.
    _________________
    [b] Mark O'Brien

    [ This Message was edited by: Mark O'Brien on 2002-04-05 13:32 ]

    [ This Message was edited by: Mark O'Brien on 2002-04-05 18:07 ]

  5. #5
    New Member
    Join Date
    Apr 2002
    Location
    Kansas
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks Mark... that should come in very handy.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com