Customising an error message
If I read the code naively, then the last open on "Word.Do***ents.open"
is a method, not an object. So, this line should throw an error to the
effect that no do***ent is found. And really, you have created a world
of confusion for yourself by naming your Word Application Object
"Word". You should be using naming practices to make clear what the
objects are in lines of code removed from where you create them.
So, you should use something line the following for the first object:
Set myWordApp = CreateObject("Word.Application")
and you should test that object to see if you created it.
Then, if Word were structured like Outlook, and it really isn't, you
would have to create a Do***ents collection object. But, in looking
quickly through my last custom form using Word Do***ents, I find where
the do***ent object is created, and the next thing I see is where a
template is added:
myWordApp.Do***ents.Add strWordTemplate
myWordApp.Visible = True
myWordDoc = myWordApp.ActiveDo***ent
In any case, I think you need to find an example of working with Word
do***ents through Outlook, set up a VBA project, set references to the
several Word object models, and get creative with the Object Browser
(F2) to find the names of the objects you need to use, and the name of
the methods you will have to use, and find out what each does.
This is no easy task for a hard day's night's burning of the midnight
oil. It will probably take several weeks. Be sure and tell your
supervisor so time will be allocated for the task.
I think you can find a relevant code example on http://www.outlookcode.com .
I found my starter example on an old, old web-site, and I would not
recommend anyone else go that route.
--
Hollis Paul
Mukilteo, WA USA
|