XPost: microsoft.public.excel, microsoft.public.excel.programming
In article <16c6f4b4a8ff960a$1$43267$
[email protected]>,
[email protected] says...
Peter T wrote:
On 28/12/2021 06:18, Robert Baer wrote:
Peter T wrote:
On 27/12/2021 07:26, Robert Baer wrote:
Problem: the "Private Declare Function ShellExecute Lib
"shell32.dll" Alias "ShellExecuteA" () produces the error message
"Only comments may appear after End Sub, End Function, or End Property" >>>>
So I moved the #If..#End If to after the End Sub; no joy.
No don't do that, the APIs must be declared at module level.
* Have no way to access module level, unless there a hidden trick.
All API's should be declared (ie written) at the TOP of a module, in
this case a 'normal' module.
The term "module level" means the TOP of a module where any any code
goes that is not a procedure eg like your Sub SendEMail(). This is where external functions (APIs) are 'declared', also variables which you want
to retain 'scope' and possibly share with multiple procedures.
As I mentioned your code really does work. If still struggling upload a workbook with it to a file sharing site and post the link.
Peter T
I have another option to send emails: send personalized mass emails
to a list from Excel via Outlook.
So I follow the script:
1. Launch a new blank Word document, and then click Mailings > Select Recipients > Use an Existing List.
2. In the Select Data Source window, choose the workbook which includes
the data range that you want to use, and click Open button.
Well that is impossible, because there is NO Select Data Source anywhere.
So it seems that there is no way in heck i can send e-mails from a
list, and will be forced to do it one-by-one manually, 2500 times.
Thanks, R. Baer
If you have Outlook application available then that's the way to go. I saw your original (and creative!) solution was to build a 'mailto:' link and then try to 'click' it within the VBA - I wouldn't have time to experiment with that but I was surprised! If you have Outlook installed, you can simply create an instance of it within your Excel VBA, and that gives you all the options you could want. This link (which I haven't studied in depth, so look for others if you hit snags) seems to run through the process, and you can adapt what it sends to suit your needs.
https://www.automateexcel.com/vba/send-emails-outlook/
--
Phil, London
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)