|
-
Feb 3rd, 2008, 07:08 AM
#1
Thread Starter
New Member
Emailing results from XL automatically
Hi everyone,
Following on from si the geek's post on automating excel (http://www.vbforums.com/showthread.php?t=391665), I would really like to hear from anyone who could give advice on automatically e-mailing data from a spreadsheet prior to saving and closing.
Thank you very much!
vcoder
-
Feb 3rd, 2008, 04:13 PM
#2
Re: Emailing results from XL automatically
You can use SendObject in the Workbook_BeforeSave event in Excel.
http://www.vbforums.com/showthread.php?t=402068
Thread Moved
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 3rd, 2008, 05:01 PM
#3
Thread Starter
New Member
Re: Emailing results from XL automatically
Thanks for your reply RobDog,
Could this be applied to worksheets within a workbook, because the workbook I am dealing with has a file size of at least 15MB. Alternatively, saving select results to a txt file is fine. Can I adapt the code to e-mail a newly saved txt file? I would be grateful if you could point me in the right direction.
Many thanks,
vcoder
-
Feb 3rd, 2008, 05:33 PM
#4
Re: Emailing results from XL automatically
No, that only thing you can email with that method is a workbook.
You can write all your desired data to a secondary temp workbook, open and email from within that instead so your not emailing the entire workbook.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 4th, 2008, 06:05 PM
#5
Thread Starter
New Member
Re: Emailing results from XL automatically
I see, for your help RodDog.
Best regards,
vcoder
-
Feb 4th, 2008, 06:20 PM
#6
Thread Starter
New Member
Re: Emailing results from XL automatically
Hi Rob,
Coming back to this, would you happen to know of code to e-mail a text file? It's just that I prefer to write my results in this way if possible.
Thanks,
vcoder
-
Feb 5th, 2008, 04:15 AM
#7
Re: Emailing results from XL automatically
to send an email from vb /vba, there are several methods, the simplest is
shellexecute "mailto" , but this requires the user to press send
you can automate outlook to send email
otherwise you need to look into cdont,
or vbsendmail, which you can reference the dll to use the sendmail class, but you would need to get the winsock ocx
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 5th, 2008, 04:07 PM
#8
Thread Starter
New Member
Re: Emailing results from XL automatically
Hi Westconn,
Thanks for your reply. Would you happen to know of any tutorials on the methods you mentioned?
Thanks,
vcoder
-
Feb 6th, 2008, 05:38 AM
#9
Re: Emailing results from XL automatically
robdog has tutorial for sending with outlook, see top post this forum
search in the vb6 forum for vbsendmail, or google it and download the vbsendmail class and sample vb programs with the instructions
if you don't have vb6 you will not be able to run the sample programs, but the code is easy enough to convert to vba, once you add a reference to the dll, make sure to register the dll
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|