Event when a document is opened?

P

pnp

Hi.

In our company our templates is somewhat depending on the feature that has
been cancelled in word 2003. That headers and footers update when you open a
document. Therefore a macro has been created and we want to use this. I would
like this macro to run as silent as possible (meaning no matter the macro
security it should still run without prompting anyone)

I have the following scenario.
A global template located on a network share. The template is placed in the
same folder as the Workgroup template locations.
Templates in the Workgroup template location
And documents referencing the above mentioned templates.

My question is now how I add code that runs this macro that updates the
header and footers.

Is it enough if i place the code in the open event of the template. Will
that cause the macro to be run when the document based on that template is
opened?

Otherwise - is there a way in my global template i can receive an event from
the application that a new document is being opened - and i can then call
this macro on that document.

Any help is appreciated.

/Anders
 
J

Jean-Guy Marcil

pnp was telling us:
pnp nous racontait que :
Hi.

In our company our templates is somewhat depending on the feature
that has been cancelled in word 2003. That headers and footers update
when you open a document. Therefore a macro has been created and we
want to use this. I would like this macro to run as silent as
possible (meaning no matter the macro security it should still run
without prompting anyone)

If the security is set to "High" then there is nothing you can do, macros
will not run by default, unless the templates are in one of the "trusted"
folders (Start-up, User templates, Workgroup templates) or are signed; and
that the option to trust installed add-ins is check on the Trusted sources
tab of the Macros security dialog.
The same with Very high applies, but then users will get a warning that
macros have been disabled, but if they are in a trusted folders, they will
run anyway.
I have the following scenario.
A global template located on a network share. The template is placed
in the same folder as the Workgroup template locations.
Templates in the Workgroup template location
And documents referencing the above mentioned templates.

My question is now how I add code that runs this macro that updates
the header and footers.

Is it enough if i place the code in the open event of the template.
Will that cause the macro to be run when the document based on that
template is opened?

Yes.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
Z

zkid

You stated that the macro worked before upgrading to Word 2003. Does the
macro work if you run it manually after you retrieve the desired document?

If it isn't working, then your problem is a bit of changed coding in 2003
VBA. If your macro was written for versions prior to Word 2000,
headers/footers access changed drastically in VBA and you will need to
re-code portions. What exactly are you updating? Field codes? Text?

If it IS working, then you have an issue with AutoNew. If your company is
now using a document management system (i.e., DocsOpen, iManage, Worldox,
etc.), unfortunately, those programs typically shut off your access to the
Auto-type macros (i.e., AutoNew, AutoOpen, AutoClose, AutoExec, AutoExit).
If this is the case, you will need to request your users to execute the macro
- there is no way around it.

Please let us know.

zkid
 
P

pnp

Well.. Not exactly.

I might not have explained it thoroughly enough. In the previous version of
word the macro was not necessary, since word itself updated the headers and
footers.

The macro itself is working correct - the issue is getting in placed
somewhere, prefereble in its own file, and then referencing this code from
all other templates.

I think Jean-Guy is on the right track, ill try that now and see if it
solves the problem.

/Anders
 

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