Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Piplodocus

macrumors 6502a
Original poster
Apr 2, 2008
543
549
I'm trying to make a script of sorts, to copy from the currently selected cell of Excel:Mac, then paste into a VMWare Windows 7 command window that's already open.

I tried VBA with 'appactivate' to try to select the command window by name, then was gonna do sendkeys to paste: no joy yet (would work in windows, but never used much VBA in excel for mac).

Thought maybe I'd try automator: doesn't work in the end with excel copy function, the the 'watch what I do' functions to select the command window, and alt-space, e, p, to paste in a windows command window.

Tried going for an applescript spin-off of that and can't seem to active that boot camp window successfully (I'm running 'Unity' view as figured that'd help with my first method).

I'm not used to any of the mac automator/applescript functions (even though I'm a mac user at home) so am a bit lost. I also don't know if I should name the thing to activate by window caption, VMWare, or what since it's running in a virtual machine. Any ideas or pointers in what direction I should be heading, or if this is an impossible feat?
 
I got this to work using AppleScript.

However, this may not be the most reliable way to get the data over as it is possible for vmtoolsd.exe to get out of sync with what is on the OS X clipboard. Adding a delay in the AppleScript helped for my data, but may not cover all cases.

AppleScript Code:

Code:
tell application "Microsoft Excel" to activate

tell application "System Events"
    tell process "Microsoft Excel"
        keystroke "c" using command down
    end tell
end tell

tell application "VMware Fusion" to activate

tell application "System Events"
    tell process "VMware Fusion"
        delay 2 -- Need delay to allow VMware Tools 10.0.1 (Fusion 8.5.3) to catch up.
        keystroke space using option down
        keystroke "e"
        keystroke "p"
        key code 58 -- Need ALT keystroke as sometimes VMware Fusion 8.5.3 thinks ALT key still down.
     
    end tell
end tell
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.