Link to home
Start Free TrialLog in
Avatar of elkor
elkor

asked on

Again: SendKeys and Word

it's don't work:
Shell "WinWord", vbMaximizedFocus
DoEvents
SendKeys "%FO", True
_______________________________

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


Why? :)
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

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
Avatar of elkor
elkor

ASKER

to JDettman:
 no, it's doesn't work :(

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

ASKER CERTIFIED SOLUTION
Avatar of perove
perove
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elkor

ASKER

to perove:
yes, it's works :)
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!!!