My requirement is to copy a content from excel, open terminal app, paste the copied content in terminal and execute

1

I am new to VB - So please guide me [Currently Terminal is opening up, but the focus still remains in excel. I want to paste a copied value in terminal app. guide me guys]. I am using Excel for mac 2011 [VB 14.1]

Code to paste is not written in the below code:

Code used:

Sub Auto_Open()

   Range("A1:A1").Select
   Selection.Copy

Externalapp = Shell("Macintosh HD:Applications:Utilities:Terminal.app:" & _
              "Contents:MacOS:Terminal", vbNormalFocus)
AppActivate Externalapp

    End Sub

Raja Shekar

Posted 2017-12-20T20:01:51.200

Reputation: 11

1I'm not familiar with the AppFocus function, but I've only used Excel VBA on Windows. What about trying the literal value of 1 instead of vbNormalFocus? Shell("Macintosh HD:Applications:Utilities:Terminal.app:Contents:MacOS:Terminal", 1) – davidmneedham – 2017-12-20T21:59:40.843

Not working :{ My current code is as below: – Raja Shekar – 2017-12-21T04:33:30.870

Sub Macro2()

Externalapp = Shell("Macintosh HD:Applications:Utilities:Terminal.app:Contents:MacOS:Terminal", 1)

End Sub – Raja Shekar – 2017-12-21T04:34:58.753

What about using the AppActivate function instead? – davidmneedham – 2017-12-21T15:02:44.870

I've also had issues with an external program losing focus when running a sub-procedure from the immediate window. If it is ran from the menu within Excel, you may have better results. – davidmneedham – 2017-12-21T15:05:37.547

Do you mean like this?? Externalapp = Shell("Macintosh HD:Applications:Utilities:Terminal.app:" & _ "Contents:MacOS:Terminal", vbNormalFocus) AppActivate Externalapp – Raja Shekar – 2017-12-21T16:37:08.963

Yes, that's what I mean. If that doesn't work, you may have to try AppleScript or MacScript. I suggest editing your question to include what you have tried and including the version of Excel you are using (likely Excel 2011 or Excel 2016). – davidmneedham – 2017-12-21T16:59:44.280

I have updated the content. Kindly help. – Raja Shekar – 2017-12-22T06:59:28.643

No answers