Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | Advanced VBA (28 exercises) |
Topic ==> | Links to other applications (3 exercises) |
Level ==> | Relatively easy |
Subject ==> | VBA training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
Open the Excel workbook in the above folder - it contains the names of the children for whom you have to buy presents, and what they want:
Someone has thoughtfully created a range name called Children.
Open the Word document in the above folder, and you'll see that it contains a (brief) letter to Santa, containing two bookmarks:
The idea is that your Excel macro will substitute in each child's present request at the first bookmark, and their name at the second one.
The bookmarks have the following names:
Bookmark | What will be put there |
---|---|
Present | The name of the desired present |
ChildName | The name of the child requesting this |
Close this Word document down, and create a macro in the Excel workbook which loops over the children's names, and for each:
Opens the Word document.
Goes to the Present bookmark and writes in the child's present request.
Goes to the ChildName bookmark and writes in the child's name.
Saves this document, using the child's name as a file name.
You may find the following macro useful as a hint:
Sub Hint()
Dim doc As Document
'open up the Word document, getting a reference to it
Set doc = Documents.Open("E:\Referencing applications\Dear Santa.docx")
'go to this document
doc.Activate
'write in a present name
doc.Bookmarks("Present").Range.Text = "A really fluffy owl"
'write in the child's name
doc.Bookmarks("ChildName").Range.Text = "Wally Owl"
'save this document, and close it
doc.SaveAs2 "E:\Referencing applications\Wally Owl"
doc.Close
End Sub
Test that your macro contains one letter for each child, then save it as Suffer the little children.xlsm and close it down, reflecting on another tedious Christmas task now automated!
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.