New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Apps and Games Discussion of applications and games available for Mac OS X.

Send Excel workbook as attachment


Post Reply New Thread Subscribe

 
Thread Tools
cmhoz

 
Member Since: May 27, 2007
Posts: 3
cmhoz is on a distinguished road

cmhoz is offline
I am desprately seeking a way to send an Excel workbook as an attachment to WHATEVER the default mail program is (in this case, OS X Mail).

I have a cross platform file - If the user is on a Windows system, there are lots of easy ways to send email. However, when the user is on a Mac OS X machine, the default mail options do not work (because they are linked to Outlook). SO... here's what I've tried...

1.
ActiveWorkbook.FollowHyperlink _
"mailto:me@isp.org" & _
"?subject=I have a dream.." & _
"&body=That one day soon this will work!"

Great. Calls up the default mail program. But - doesn't attach the current workbook.


2. Application.Dialogs(xlDialogSendMail).Show

3. All the different PC options... they all fail in OS X.

This is what excel generates what I record a macro to send workbook as attachment. But - when I play it back, it generates a runtime error and claims that xlDialogSendMail isn't valid.

HELP!!! There has to be SOMEONE out there who knows how to send an excel workbook on a Mac.... I just can't work it out, have even tried looking for an AppleScript solution, but that's a whole new world to me, so I'm very lost.
QUOTE Thanks
shades

 
Member Since: May 20, 2004
Posts: 243
shades is a jewel in the roughshades is a jewel in the rough
Mac Specs: iMac 21" 8GB, MBP 15" 2.5 Penryn, 4 GB/180 GB

shades is offline
Howdy. Several problems: DilaogSendmail does not work on Mac, despite the recordability. Also, the reference to files is slightly different on the Mac than on Win. Also, here is one approach using Entourage (Mac step-sister of Outlook).

Jim McGimpsey Mac MVP has put togehter both VBA and AppleScript to do what you need. Send attachments with Entourage
QUOTE Thanks
shades

 
Member Since: May 20, 2004
Posts: 243
shades is a jewel in the roughshades is a jewel in the rough
Mac Specs: iMac 21" 8GB, MBP 15" 2.5 Penryn, 4 GB/180 GB

shades is offline
BTW, Entourage does not support VBA, so AppleScript is the only way to go.
QUOTE Thanks
cmhoz

 
Member Since: May 27, 2007
Posts: 3
cmhoz is on a distinguished road

cmhoz is offline
Excellent....

I tried the VBA solution and it works perfectly with Mail, but as there is not way to auto add the recipient or subject, I would like to try the AppleScript solution.

I've tried to make a small change to the code so it calls Mail instead of Entourage... but I get this error: "Invalid procedure call or argument."

This is the code:
Code:
Public Sub MailSendMail(theBook As Workbook, _
            recipient As String, subject As String)
        Dim mailStr As String
        
        mailStr = _
            "Tell application ""Mail""" & vbNewLine & _
            "make new outgoing message with properties" & _
            "{recipient:""" & recipient & """,subject:""" & subject & _
            """,attachment:""" & theBook.FullName & """}" & vbNewLine _
            & "move the result to out box folder" & vbNewLine & _
            "send" & vbNewLine & _
            "end tell"
            
        MacScript mailStr
        
    End Sub
    
    
    Sub sendit()
        MailSendMail ThisWorkbook, "jodcmh@bigpond.net.au", "this is the subject"
    End Sub

I'm guessing that's because there the script for Mail is slightly different than that for Entourage... but I'm not sure where I need to change things. I've tried running the script in script editor and it fails at 'move to out box folder'. If I remove this, it appears to run, but no mail item is actually sent.

Thanks for any help... AppleScript is brand new to me.
QUOTE Thanks
cmhoz

 
Member Since: May 27, 2007
Posts: 3
cmhoz is on a distinguished road

cmhoz is offline
Almost got it!

Made some changes... now it looks like this:
Code:
    Public Sub MailSendMail(theBook As Workbook, _
            recipient As String, subject As String)
        Dim mailStr As String
        
        mailStr = _
            "Tell application ""Mail""" & vbNewLine & _
            "make new outgoing message with properties" & _
            "{recipient:""" & recipient & """,subject:""" & subject & _
            """,attachment:""" & theBook.FullName & """,visible:true}" & vbNewLine _
            & "end tell"
        MacScript mailStr
    End Sub


Sub sendmessage()
    MailSendMail ThisWorkbook, "name@address", "This is the subject"
End Sub
BUT... the recipient isn't showing up in the message. Subject is fine, but no recipient....
QUOTE Thanks

Post Reply New Thread Subscribe


« DVD decrypt/burning software | Simple Automator question »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Switcher - Excel & Word for Mac? mab OS X - Apps and Games 17 03-04-2008 11:05 AM
powerpoint attachment macextra OS X - Apps and Games 9 05-26-2007 12:32 PM
Inputting foreign characters into Excel - ?? rickhess Running Windows (or anything else) on your Mac 0 04-26-2006 11:47 AM
Strange attachment issue RobbGraves Running Windows (or anything else) on your Mac 0 12-07-2004 04:39 PM
Excel attachment huffstar Running Windows (or anything else) on your Mac 12 06-03-2004 01:16 PM

All times are GMT -4. The time now is 12:50 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?