Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Sep 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word2K(SP1), Win2K and Send Keys Method (Work 2000 SP-1)

    Has anyone had problems with the "sendkeys" method in Word 2K under Win2K?

    The following macro, which opens the File|New dialog in details view and at a particular folder, worked
    well under Win98 and works well now in Excel under Win2K ... but not in Word.

    Sub FileNew()
    'Change the SendKeys statement to "%1" for Large Icon view or
    'to "%3" for Detail view.
    SendKeys "%2"
    SendKeys "+{TAB}"
    SendKeys "{UP}"
    SendKeys "{RIGHT}"
    SendKeys "{RIGHT}"
    Dialogs(wdDialogFileNew).Show
    End Sub

    Current references are:

    Visual Basic for Applications
    Word 9.0 Object Library
    Office 9.0 Object Library
    OLE Automation

    These are also the references shown in Excel

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Word2K(SP1), Win2K and Send Keys Method (Work 2000 SP-1)

    The code seems to work fine for me in Word 2000, in that it opens the FileNew dialog box and tabs a few time to select a folder.

    Where or how is it giving you problems ?

    Andrew C

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word2K(SP1), Win2K and Send Keys Method (Work 2000 SP-1)

    My question is, why does this work at all? Wouldn't you think that the keyboard buffer would start typing out these keystrokes before the dialog had time to load? Hmmm...

    I'm afraid I don't see any other way to manipulate the FileNew dialog, in that it doesn't take the .DefaultTab parameter. And the way Word organizes these templates internally appears to be inaccessible programmatically. On the other hand, if you are only interested in a particular subset of templates, you could populate your own userform from the folder in which they reside, bypassing the FileNew dialog altogether.

  4. #4
    New Lounger
    Join Date
    Sep 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word2K(SP1), Win2K and Send Keys Method (Work 2000 SP-1)

    when the code is executed the file new dialog opens:
    1. In large Icon view
    2. in the general folder
    in other words, in the default view.
    Strangely, this exact same code works in Excel under the same circumstances.

    I initially had this problem when I "upgraded" to Win2K over Win98SE. For many reasons, and this was one of them, I formatted my hard drive and "clean" installed Win2K. This problem remains.

    It puzzles me that the code works in Excel, using xlDialog.new of course.

  5. #5
    New Lounger
    Join Date
    Sep 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word2K(SP1), Win2K and Send Keys Method (Work 2000 SP-1)

    Your points are well taken, however, this code, as shown, worked in Word 2K under Win98SE and currently works in Excel, using "Application.Dialogs(xlDialogNew).Show".

    Please try it yourself, if you have the time and inclination.

    There are other ways to accomplish this, but, using no more than ten lines of code always works for me.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word2K(SP1), Win2K and Send Keys Method (Work 2000 SP-1)

    I did try yours before I posted, and it worked for me in Word 2000 on Windows 98. But...I still don't understand why SendKeys works that way. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    A search at MS turned up some SendKeys-related articles for Windows 2000:
    <A target="_blank" HREF=http://support.microsoft.com/support/kb/articles/Q297/1/08.ASP>BUG: Visual Basic SendKeys Causes Incorrect Keyboard Status or Freezes Keyboard (Q297108)</A>
    <A target="_blank" HREF=http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;Q276346>FIX: SendKeys Function Locks Keyboard on Windows 2000 (Q276346)</A>

  7. #7
    New Lounger
    Join Date
    Sep 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word2K(SP1), Win2K and Send Keys Method (Work 2000 SP-1)

    I agree with your logic. And I have tried rearranging the code but the method shown is the only one that works.

    Thank you for your interest.

Posting Permissions

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