Caspar has attended:
Excel VBA Intro Intermediate course
VB Mail Merge
Hello - I asked on my course about what happened if you wanted to use visual basic with a mail merge document as opposed to just an ordinary one.
I was told that this was one for the Support Forum, but that there was such a thing as visual basic for mail merging.
Do I simply record a macro in a mail merge document and then proceed as if it is an ordinary one or is there some special functionality that I should perhaps be aware of?
[Hopefully one of your easier questions today(!). No need for a lengthy answer.]
RE: VB Mail Merge
Hi Caspar
Here are a couple of links about mailmerging from Excel.
Say a little more what you need the macro to do.
http://www.cpearson.com/excel/Email.aspx
http://www.ozgrid.com/forum/showthread.php?t=45882
Thanks
Doug
RE: VB Mail Merge
Hi Caspar
Thanks for getting in touch. I hope you found your course useful and enjoyable.
Mail merge is perfectly possible within VBA. There are a few factors, such as where is the source data and what are merging to (e.g. labels, letters). You probably require a little knowledge on how to 'talk' to Word VBA from Excel VBA.
In Excel VBA you should go to Tools > References and add "Microsoft Office Object Library" (there will be a number in this representing the version of Office you are using). This will give you access to Word's VBA library. From then on you will need the appropriate code from recording a mail merge macro in Word.
This technique has a few twists and turns so for full information I recommend you attend our VBA Advanced course where we deal with communicating between Office applications. In the interim, I have found this decent discussion thread to give you some pointers:
http://www.ozgrid.com/forum/showthread.php?t=30692
I hope this helps, let me know how you get on.
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Will be marked as resolved in 5 days
Notice: This is an automated message. Due to inactivity, this forum post will be marked as 'resolved' if there are no further responses in the next 5 days.