Consulting

Results 1 to 5 of 5

Thread: Edit with TextEdit via VBA

  1. #1

    Edit with TextEdit via VBA

    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.)

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    This worked for me
    [VBA]Dim scriptStr As String

    scriptStr = "activate application ""TextEdit"""
    scriptStr = scriptStr & vbCr & "set miniaturized of window 1 of application ""Microsoft Excel"" to true"

    MacScript (scriptStr)[/VBA]

  3. #3
    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.

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    [VBA]Sub test()
    Dim strScript As String
    strScript = strScript & "tell application ""TextEdit"" " & vbCr
    strScript = strScript & "open ""Macintosh HD:Users:mericksonocuments: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
    [/VBA]

  5. #5
    Yessssss!! Perfect. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •