View Full Version : Edit with TextEdit via VBA
Pathagoras
09-26-2011, 04:01 AM
I need to call Mac's Text editor ("TextEdit") using the shell command in a VBA project.
I was hoping it would be as simple as:
Shell("TextEdit (mytextfile)")
but there is apparently more to it in Apple.
Any ideas. (The Apple Script editor didn't help much.)
mikerickson
09-27-2011, 06:22 PM
This worked for me
Dim scriptStr As String
scriptStr = "activate application ""TextEdit"""
scriptStr = scriptStr & vbCr & "set miniaturized of window 1 of application ""Microsoft Excel"" to true"
MacScript (scriptStr)
Pathagoras
09-28-2011, 04:23 AM
Mike, Thanks. My top question was incomplete. It should have read:
"I need to call Mac's Text editor ("TextEdit") using the shell command in a VBA project and automatically display a specified text file."
It's the second part that is the most critical to my need. Thanks again.
mikerickson
09-28-2011, 06:33 AM
Sub test()
Dim strScript As String
strScript = strScript & "tell application ""TextEdit"" " & vbCr
strScript = strScript & "open ""Macintosh HD:Users:merickson:Documents:Lyrics:Roll in my sweet baby's arms (explicit).rtf"" " & vbCr
strScript = strScript & "activate" & vbCr
strScript = strScript & "end tell"
MacScript strScript
AppActivate "TextEdit", True
End Sub
Pathagoras
09-28-2011, 10:27 AM
Yessssss!! Perfect. Thanks.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.