Solved

Again: SendKeys and Word

Posted on 2001-06-29
5
758 Views
Last Modified: 2009-07-29
it's don't work:
Shell "WinWord", vbMaximizedFocus
DoEvents
SendKeys "%FO", True
_______________________________

it's works:
Shell "Excel", vbMaximizedFocus
DoEvents
SendKeys "%FO", True


Why? :)
0
Comment
Question by:elkor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 57
ID: 6238126
Most likely because of timing differences.  Depending on what is going on on the PC at the moment, you may be at different points of a program startup when SendKeys gets executed.

 To make that clear, you may find that on a different PC, even the Excel won't work.

To see if it is a timing issue, paste the function below  into a module, then add:

  intRet = Wait(15)

  Before the SendKeys.  If that doesn't work, then it's something else.

Jim.



Function Wait(intSeconds As Integer) As Integer

    Dim datCurDateTime As Date
    datCurDateTime = Now
   
    Do Until DateDiff("s", datCurDateTime, Now) > intSeconds
      DoEvents
    Loop
   
End Function
0
 

Author Comment

by:elkor
ID: 6238154
to JDettman:
 no, it's doesn't work :(

_________________________________________
for example next statment works:
    Shell "WinWord", vbMaximizedFocus
    DoEvents
    SendKeys "%{F4}", True

0
 
LVL 9

Accepted Solution

by:
perove earned 50 total points
ID: 6238188
You are so right, It does NOT work.

this will work:

Shell "WinWord", vbMaximizedFocus
DoEvents
SendKeys "%"
SendKeys "F"
SendKeys "O", True

..but I don't know why

perove


0
 

Author Comment

by:elkor
ID: 6238235
to perove:
yes, it's works :)
0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 6238976
This is an odd bug in Word 97 that you've uncovered.

All the top-level menus in Word respond as normal to the Alt+Key , Alt-E for Edit, Alt-O for format etc. i.e. those key combinations drop down the corresponding menu. The exception is that Alt-F does NOT open the File menu, instead it just selects it on the menu bar!

This SendKeys sequence works...

Shell "winword", vbMaximizedFocus
SendKeys "%f{down}o"

Note that there is no need for DeEvent, it works as is. Note also that it's CASE SENSITIVE , you have to use a lowercase 'f'. Go figure!!!

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question