Trying to set up a Macro that will keystroke "alt + tab" keys

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • toddinator
    New Member
    • Aug 2007
    • 3

    Trying to set up a Macro that will keystroke "alt + tab" keys

    Here's the situation....

    I have a Word doc open and an Excel workbook open. I can easily toggle between the 2 open files by pressing Alt&tab. What I'd like to do is to set up a macro in Word to copy some text , then toggle to my open excel workbook and paste it after I do a "cntl+F". Eventually there will be quite a bit more to this macro, but I'd like to start here. Can anyone help?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by toddinator
    ... set up a macro in Word to copy some text , then toggle to my open excel workbook and paste it ...
    Look up SendKeys in the VB/VBA doco.

    Comment

    • toddinator
      New Member
      • Aug 2007
      • 3

      #3
      Originally posted by Killer42
      Look up SendKeys in the VB/VBA doco.
      Thanks for the answer back. I've done that, and it works quite well. As I add more code to this macro though, it doesn't really like the fact that I start in MS Word and go to Excel. Once I toggle with the SendKeys "%{TAB}" function, how do I then make the Excel Workbook the active file? I've been told that SendKeys is a poor way to automate code. Any other suggestions?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by toddinator
        Thanks for the answer back. I've done that, and it works quite well. As I add more code to this macro though, it doesn't really like the fact that I start in MS Word and go to Excel. Once I toggle with the SendKeys "%{TAB}" function, how do I then make the Excel Workbook the active file? I've been told that SendKeys is a poor way to automate code. Any other suggestions?
        Oh, definitely! SendKeys is very much a "quick and dirty" way to drive another application. If you can use automation to do the job, it'll be much more reliable.

        I'm a bit rusty on how, but try doing some searching on a mixture of terms like VB and Excel and automation here at TheScripts, you should find quite a bit of information.

        Comment

        • toddinator
          New Member
          • Aug 2007
          • 3

          #5
          okay, I appreciate the help!

          Comment

          Working...