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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a new document from within the closing document

Status
Not open for further replies.

PStrongs

Instructor
Oct 30, 2007
30
0
0
GB
Hi All,

I have a template that a user opens and produces many 'child' documents from. Rather than the user having to save the child and then open a new parent (template) document manually every time, is there any way to fire up the template after saving the child with Document.SaveAs?

I have tried to do this, but after the template document is opened with Document.Open from within the now child document, focus is lost and the Document.Close will not execute from the child document.

I would like a dialog that says something like: 'Would you like to create another document?' and if the user clicks yes, then the child document closes and a new template fires up.

It would be a great time saver, but not sure if it is possible.

Regards,
 
Try Documents.Add
and specified a template name to create new documents
 
Hi White605,

thanks for the post. Hope to give it a try and see if it works. Will this work for documents that are not Templates? i.e. a document that is on the users hard disk and not in the Templates folder?

Regards,
 
Have you tried specifing the document name you want to close. Are you making sure the document you want to close is the active document are you using just document.close


ck1999
 
Are you actually using templates? Are you cloning a new document from the template with File > New?

I always wonder when people use the phrase "open a template". User should NEVER, EVER, open a template.

In regard to your original questions, I would add a "make new document" button, or menu item, or shortcut key....whatever. Have that in your normal.dot, or better, in a global template.

THAT would clone a new document from the template.

The user does what they do with the child document. SaveAs.

Hits the button/menu item.shortcut key again, and gets a new document.

Second best, would be as White605 suggests. Add code in the template file that would clone a new document.

As for:
Will this work for documents that are not Templates? i.e. a document that is on the users hard disk and not in the Templates folder?
This is irrelevant.

The location of template (.dot) files only has relevance to having a location that Word knows about. A .dot (template) file can be invoked and cloned from ANY file location.

A .dot file on the user hard disk, is just the same as a .dot file in the Templates folder. A .doc (document) file in the Templates folder does not make it a Template, it is still a document. A template (.dot) file on the user hard disk is still a template.

faq219-2884

Gerry
My paintings and sculpture
 
ck1999/fumei,

thank you for your posts. I like the idea that fumei put forward and trigger the document from a menu button. This would probably be more reliable and more user friendly anyway.

Just to clarify the problem that i had for info only:

the master document was a .doc document stored on the user hard drive. When activated, a user form appeared asking for information. The macro would populate the form from the data that the user entered and then saved the 'child' from the master under a name that was incrementally created from the user form data in another folder where all the 'child' documents would be stored.

Because this was a repetitive tasks (perhaps 50 documents or so in one hit), then I thought it would be a great time saver for the user to have the master document open again for another 'child' document to be created.

Rather than have 50 'child' documents open all at the same time, I was looking for a way to close the 'child' before the master document was opened again to create another 'child' and so on.

Anyway that was the theory, but I think fumei has given an alternative solution that will work in this instance.

Thank you both for your contribution.

Regards,
 
PStrongs,

[offtopic]

How did you make out with my solution to your problem moving text from table to table? I'd like to know if it worked for you as well as it did for me.

[/offtopic]

[glasses]

----------------------------------------------------------------------------------
[small]How did the newspaper describe the swindler who fell off the prison roof during an escape attempt?[/small]
[spineyes]They used a condescending remark.[bugeyed]
 
Hi Walker Evans,

Just haven't had the time yet to try it out. I am back in the office in a couple of days, so will give it a go then and let you know.

Regards,
 
Hi Everyone,

I revisited this problem with opening a document from the closing document and have found a solution. Quite simple really: Set the opening document UserForm to Modaless. Focus is maintained in the Closing document and passes to the opening document when the routine in the closing document ceases to exist.

I need to test it on live documents, but when playing around with the code recently it seemed to work with no visible errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top