vb mail merge

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

VB Mail Merge

resolvedResolved · Low Priority · Version 2002/XP

Caspar has attended:
Excel VBA Intro Intermediate course

VB Mail Merge

Hopefully just a quick question:


When using VB with a mail merge, is there a standard way of saying

'execute this sub automatically as the merged document is brought up after the mail merge rather than waiting for a user to run it'?

RE: VB Mail Merge

Hi

Thanks for getting in touch. Assuming you start your mail merge process in Excel, where you usually start a macro with

sub MyMacro()

You should have something like this

Private Sub Workbook_Open()

To recreate this code you can go to your Project Explorer in the VBE, select the ThisWorkbook object, then over the top of your code are two drop-downs. In the first select Workbook, and the second Open.

I hope this helps.

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

RE: VB Mail Merge

Thanks for your prompt response. I've had no difficulty with the drop downs and clicking, but the subsequent macros do not seem to run automatically when the merge output opens.


Should it be


Private Sub Workbook_Open()

End Sub

Sub MyMacro()

...

...

End Sub



or


'Private Sub Workbook_Open()' instead of the text 'Sub MyMacro()' and then End Sub?


RE: VB Mail Merge

Hi Caspar

Just to be clear, it should look like this:

Private Sub Workbook_Open()

...
<mail merge code goes here>
...

End Sub

Does that help?

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

RE: VB Mail Merge

Thanks - I've taken a note of the answer and I'm happy for this call to be closed - I do have another question to follow, though.

Fri 8 Mar 2013: Automatically marked as resolved.

 

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.


 

Excel tip:

Create and delete borders

To put a border around the outside of a selected range, press Ctrl+Shift+&. Use Ctrl+Shift+_ (underscore) to remove any borders from a range.

View all Excel hints and tips


Server loaded in 0.08 secs.