?
Solved

Again: SendKeys and Word

Posted on 2001-06-29
5
Medium Priority
?
767 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 58
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 150 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

770 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