Running a macro/proc automatically

P

paoloricardo

I have created a .dot template which creates either a business or
personal letter depending on options/input from a user form.

I can run the proc if I open the .dot document and then open the VB
Editor and 'run' the form.

I want to be able to create a new document - based on this template -
so that the procedures will run automatically (without the need to
open the VB Editor)

How do I achieve this?

Thanks
 
P

paoloricardo

I have created a .dot template which creates either a business or
personal letter depending on options/input from a user form.

I can run the proc if I open the .dot document and then open the VB
Editor and 'run' the form.

I want to be able to create a new document - based on this template -
so that the procedures will run automatically (without the need to
open the VB Editor)

How do I achieve this?

Thanks

OK I have figured it out. Document_New() proc in 'This Document' with
a form.Show command. I had been putting this proc in my form.
 
D

Doug Robbins - Word MVP

In a module in the template, create a macro named Autonew() that contains
the following code:

Dim myForm As frmLetterForm

Set myForm = New frmLetterForm
myForm.Show vbModal
Unload myForm
Set myForm = Nothing

replace frmLetterForm with the name of your userform (It's a good idea to
give it a meaningful name).

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top