Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Startup template that deletes itself 1

Status
Not open for further replies.

Nelviticus

Programmer
Sep 9, 2003
1,819
GB
We need to copy some styles to our users' normal.dot templates but don't want to replace the files in case they have their own macros, auto text entries and so on.

The way I thought I would do this was to place a template in the 'Word\Startup' folder that contains an AutoExec macro which copies styles to normal.dot, saves it and deletes itself so that it doesn't run every time that Word starts. However this doesn't seem possible as you can't delete the file that the code's running from.

Does anyone have any idea how I could do this?

Thanks


Nelviticus
 
Why not just leave the template with the required styles in the startup directory? Won't the styles then be available?

If you must go the route you are thinking, you could copy a bit of code to normal.dot's autoexec that checks for the existence of the style.dot, and deletes it if there.
 
Sadly not - if you put a template in Startup, everything is available apart from its styles.

Copying code to Normal.dot's AutoExec presents a similar problem - whatever code I used to put it there would run every time Word started.

I think I'm going to have to resort to an ugly solution: deploy a dummy file somewhere and check for its presence in my macro. If it's there, copy the styles then delete the dummy file, it it's not, do nothing.

Regards

Nelviticus
 
You can use registry to complete the task. The idea:
- the document with upgrade code updates Normal
- it stores (SaveSetting) a reference to itself
- next it calls the dedicated procedure in Normal.
The called procedure in Normal:
- reads the reference from registry,
- closes the file,
- kills it.
In case of problems, an AutoExec in Normal can check the registry for presence of files to delete.

combo
 
Thanks combo, have a star. I was in the middle of writing some messy code to search for a dummy file and delete it afterwards. Using the registry is much slicker.

Regards

Nelviticus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top