VBA help anyone?

Page may contain affiliate links. Please see terms for details.

radger

Veteran
Location
Bristol
This is probably me being dense, but I am trying to run a macro to send an email merge with attachments. I am using the code from here, and have followed the instructions. However, when I come to run the macro, it asks me which file I want to open. If I choose the directory, I send the email attachment, but the mail is blank, whereas if I choose the document that has the email text in, the attachment isn't attached. If I choose the original list of email addresses, the computer has a fit and I have to exit everything from task manager.
There is no mention of choosing a file in the linked instructions
Can anyone see an obvious step missing, or should I abandon it and send all 650 emails individually?:smile:
 

Hugo15

Über Member
Location
Stockton-on-Tees
No idea but you could try posting on here http://mrexcel.com/
 

Batzman

New Member
If the e-mail is blank, it sounds like it's not finding the word doc that you are trying to attach - how many attachments per e-mail are you trying to send? It looks like the code can handle as many as you like but you'll need to have them set up in your dictionary.

So if you are trying to send an e-mail (in a word doc) and an attachment, your dictionary should have 3 columns in it, the first column is the e-mail address, the second is the message (word doc) and the third should be the attachment that you are trying to send.
 

bonj2

Guest
Firstly - what do you mean by 'has a fit'? ;):rolleyes::tongue: If it's hanging, or not responding, are you sure it's not just doing its job? Sending 650 emails one by one won't be instant, it will be more like minutes than seconds.

Secondly, try to debug it - it's hard to diagnose remotely, since the operation you're trying to do is heavily dependent on (a) files you have on your computer and (:ohmy: the contents of the spreadsheet, neither of which we can see.
However, you can debug it. The first milestone will be to find out which line is causing you to be asked for a file location, but take it step by step.
Firstly, go into the VBA code (Alt+F11), put the cursor on the line
Sub emailmergewithattachments()
and press F9. It highlights the line in burgundy, yes? Now run the macro. Switch to the VBA window, it should now have a yellow line on it. Press F10. The yellow line should move downwards through the executable lines of code (known as 'stepping through').
If the yellow line disappears and doesn't come back on the next line, then it could be because the focus has switched back to Excel's window and it is asking you to choose the file, but windows has been too lazy to activate Excel's window (is Excel flashing in the taskbar?) - if this is the case, then switch back to Excel's window and remember which line caused that to happen. Then we can go from there.
 
Top Bottom