Solved

Again: SendKeys and Word

Posted on 2001-06-29
5
747 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
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

943 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

10 Experts available now in Live!

Get 1:1 Help Now