Solved

Again: SendKeys and Word

Posted on 2001-06-29
5
744 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
5 Comments
 
LVL 57

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
to perove:
yes, it's works :)
0
 
LVL 11

Expert Comment

by:LambertHeenan
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now