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!

automating Word with VBA 1

Status
Not open for further replies.

mckinlay

IS-IT--Management
Nov 16, 2006
13
NL
I am in the process of preparing some admin templates using MS word. The idea is to have a basic wizard to auto enter a few details in the template which is easy enough. What I have been asked for is a document that will display 'page 1 of x' on the first page if doc is more than one page and display nothing if not. Obviously this can't always be determined at the creating.... can anybody think of a away to do this?
 
Hi mckinlay,

Sorry, I mistook "confinfo" as the outputext.

You could put whatever your output text is into the field, where "confinfo" is shown, or you could try:
{IF{NUMPAGES}> 1 "{PAGE} of {NUMPAGES}" {AUTOTEXT "confinfo"}}

Cheers


[MS MVP - Word]
 
I have nother question I could do with some help on....

i am creating a template which requires a disclaimer on the first page if the document is only one page and on the last page if more than one. I now know how to solve this problem if the document is only two pages but have no idea how to script this if the document is over two pages! Any ideas?
 
It would be better to start a new thread for a new question but - and I haven't read the whole thread - this does appear related. A variation on the post above yours ..

[blue][tt] {IF { PAGE } = {NUMPAGES } { AUTOTEXT Disclaimer } }[/tt][/blue]

.. in the Footer (assuming you set up an AutoText containing your disclaimer) will put the disclaimer at the bottom of te last page. If it doesn't fit, it will be forced to a page all by itself.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
I'm using this already to add my disclaimer but it appears on every page and i only want it on the last page of the document.
 
You must be doing something (probably very slightly) different; Word Fields can be very difficult to get right sometimes. Spaces can be significant; my post isn't exactly how I would normally enter it but I have just tested exactly what I posted and I only get it on the last page. Also, perhaps, what is the name of your autotext (more to the point, is it a single word)?

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Thanks for that answer it works perfectly. The only problem is if i save the document as a template it doesn't work!!! the autotext info doesn't seem to be added when a new document is created by the template... any ideas? I urgently need to get this working! If I 'open' the template file it works perfectly! HELP!
 
Thanks for your help the problem is solved. I deleted my auto entries completely and recreated them. that seemed to work so it think it was something to do with moving from normal.dot to my template.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top