Help with emailing an excel worksheet


  1. Posts : 4
    Windows 10
       #1

    Help with emailing an excel worksheet


    Hello, all

    I'm a relative novice at writing VBA code and don't pretend to very knowledgeable about computers but I persevere and usually get somewhere but I've been stuck for months on what, I'm sure, ought to be a simple task.

    Quite simply, all I want to do is write a macro to email a saved excel workbook. I have found plenty of information on-line but I always hit the same problem: I keep getting the annoying message telling me that there is no email program associated to complete the task. I have, repeatedly, checked my email settings and looked into the innards of the registry but nothing has helped. In desperation, I wrote a different macro using Hyperlink to email the workbook; this seems more promising but I don't know how, automatically, to attach the workbook or insert an email heading. I'm using Windows 10, Version 1909.

    If anyone can help, I would be very grateful
      My Computer


  2. Posts : 1,223
    W10-Pro 22H2
       #2

    Saxon said:
    ... I wrote a different macro using Hyperlink to email the workbook; this seems more promising but I don't know how, automatically, to attach the workbook or insert an email heading.
    Show us what you have in your macro so far.
      My Computer


  3. Posts : 4
    Windows 10
    Thread Starter
       #3

    Emailing a workbook


    Many thanks for replying, Mngerhold. Sorry I haven't responded earlier, but personal things got in the way. Anyway, the code I have (such as it is) is:

    Sub Email_Workbook()
    Dim Subject As String, SendTo As String
    Subject = "Annual accounts"
    SendTo = "mailto:" & Sheets("Sources").[C113].Value 'Accountant's email address
    ActiveWorkbook.FollowHyperlink Address:=SendTo, HeaderInfo:="Annual accounts", NewWindow:=True
    End Sub

    It works OK and using hyperlink avoids the annoying "...there is no email program associated..." message, so I'd like to stick with the hyperlink approach, if possible. However, I would also like the program to (1) attach a workbook C:\filepath\filename automatically; (2) enter a subject line automatically and (3) enter a short standard message automatically. My attempts to achieve this have been unsuccessful (unfortunately I no longer have the code for these attempts) hence my appeal for help. If you can help me I would be very grateful.
      My Computer


  4. Posts : 99
    Windows 10 Home Version 22H2
       #4

    Why couldn't you open your Excel worksheet, click on File, Share, Email. On my system, there are various options then shown for you to choose in what form you want to send the email. At least it does on my Excel 2019.
      My Computer


  5. Posts : 1,223
    W10-Pro 22H2
       #5

    I'm afraid I may be no help. My automated emailing of files (22 years ago) was all done using Outlook, ie mm = CreateItem(olMailItem) - this way all the properties of mm can then be set, eg .subject, .attachments etc. I was not familiar with the FollowHyperlink instruction, so had to just test it - and it seems it is much more limited in what can be passed on the invocation line. See Access - Create email with a mailto hyperlink - Codekabinett

    Does the 'no email program' message mean you are not using Outlook? I have not seen that message, so have never had to deal with it. AIUI, you need to have something set as the default mail app - what is yours set to?
      My Computer


  6. Posts : 5,899
    Win 11 Pro (x64) 22H2
       #6

    Saxon said:
    Hello, all

    I'm a relative novice at writing VBA code and don't pretend to very knowledgeable about computers but I persevere and usually get somewhere but I've been stuck for months on what, I'm sure, ought to be a simple task.

    Quite simply, all I want to do is write a macro to email a saved excel workbook. I have found plenty of information on-line but I always hit the same problem: I keep getting the annoying message telling me that there is no email program associated to complete the task. I have, repeatedly, checked my email settings and looked into the innards of the registry but nothing has helped. In desperation, I wrote a different macro using Hyperlink to email the workbook; this seems more promising but I don't know how, automatically, to attach the workbook or insert an email heading. I'm using Windows 10, Version 1909.

    If anyone can help, I would be very grateful
    It would help immensely to know what email client you're using???

    Anyway, with Outlook (in my case Outlook 365 desktop app) all you need to do is attach the Excel document when sending an email...

    Help with emailing an excel worksheet-excel-attachment.jpg

    The above is a received email with an Excel spreadsheet attached. I was sent using Outlook. Not clear on why you need to write a macro to email an Excel spreadsheet? Perhaps a bit of clarity would help?

    Anyway, I can speak on Windows 10 email app as I don't use it.
      My Computers


  7. Posts : 1,223
    W10-Pro 22H2
       #7

    I believe the OP wants to launch the sending of the email from within Excel itself. It's easy enough if one uses Outlook as the email client, I don't know about others, but yes, first we need to know what they are using for email.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:01.
Find Us




Windows 10 Forums