vb mail merge

Forum home » Delegate support and help forum » Microsoft VBA Training and help » VB Mail Merge

VB Mail Merge

resolvedResolved · High Priority · Version 2002/XP

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.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Good coding practice

It is important that you always comment the VBA code that you write. By doing this it will make the code much easier to read, as both yourself and other people will be able to see what the code is doing or meant to be doing. This is very important if there is more than one person who writes code in the company as you may have different styles of coding and may not really understand what the other person is trying to do. Also if you write some code and then do not touch it for a year or so you may actually forget what it is meant to be doing. so it is very important to include comments throughout your code and try and make sure that they are as useful as possible

View all VBA hints and tips


Server loaded in 0.12 secs.