PDA

View Full Version : Solved: How do i force the SaveAs window?



TrippyTom
01-07-2008, 11:26 AM
I think this question has been asked many times, but I did a search and couldn't find it.

I need to force the SaveAs window on document close and save events. I can't use a template because it seems templates do not carry vba code with them as it opens a separate .doc format when opened. So I need to force the user to save as a new filename when done with the file.

Is there an easy way to do this?

fumei
01-07-2008, 11:47 AM
Huh?????

"So I need to force the user to save as a new filename when done with the file."

If the document is cloned from a template...they HAVE to save it as a new filename when done with it.

"I can't use a template because it seems templates do not carry vba code with them as it opens a separate .doc format when opened."

Huh???

Yes, a template does indeed "open" a separate document. It actually clones a copy of itself...and that clone has NO filename. You must use SaveAs.

Template carry ALL code with them into new document. As long as the template file is accessible.

TrippyTom
01-07-2008, 12:09 PM
Fumei:
I have a userform setup to show when the file is opened. It doesn't look like the form is saved with the new document when opened by the .dot file. So how can it show something that's not there?

fumei
01-07-2008, 12:54 PM
You are going to have to be much much more clear than that. I am not following you.

"It doesn't look like the form is saved with the new document when opened by the .dot file."

Userforms are NEVER saved, if you mean any data entered on the userform. Once the userform is unloaded...poof...ALL data on that userform is destroyed. You have to DO something with any data entered on a userform. You have to put it somewhere.

What do you mean, exactly, by "when opened by the .dot file"?

As for showing something that is not there. I have no idea what you are trying to say.

Try explaining EXACTLY what is actually happening, and what it is you want to happen.

You have a template.
You clone a new document.
The template displays a userform as part of its Document_New event, the one that actually creates the clone.

OK.

Are you asking that the new document display the userform? This can be done.

Please describe with a few more details.

TrippyTom
01-07-2008, 01:03 PM
Yes, I am asking that the new document display the userform from the .dot file. I thought that's what I said in the previous post. I'm not intentionally trying to be obscure.

fumei
01-07-2008, 01:18 PM
OK...then put code to display it in a standard module in the template (.dot) file.

Done.

fumei
01-07-2008, 01:27 PM
"Yes, I am asking that the new document display the userform from the .dot file. I thought that's what I said in the previous post."

Here is what you said.

"It doesn't look like the form is saved with the new document when opened by the .dot file. "

Does that look like you are asking the cloned document to display the userform? No, it does not. It quite clearly says it is not saved in the new document.

Which it is not, nor ever will be.

But you can display anything from the template, including a userform. If the template has a userform, any document cloned from it can display that userform. That is what templates are for.

Not worry re: "I'm not intentionally trying to be obscure."

I realize that. It takes time and persistence to ask good questions. Start by always stating clearly EXACTLY what it is you want.

Again, to answer: "Yes, I am asking that the new document display the userform from the .dot file" - simple. Have a procedure in a module in the template that calls/displays the userform.

TrippyTom
01-07-2008, 02:52 PM
Aha!
Thus a problem arises. In order to have the form shown when the file is opened, don't I need to keep it in the "ThisDocument" module? I moved it to a standard module as you suggested, but the form doesn't show when I open the file.

Private Sub Document_Open()
frmOptions.Show
End Sub


... or do I have to specify the form is in the .dot file somehow?

TrippyTom
01-07-2008, 04:59 PM
I changed the procedure to Document_New and it worked fine. I didn't have complete understanding of it (and probably still don't) but I'm closer to understanding how it works now, thanks to you all.

fumei
01-10-2008, 11:41 AM
I think there is much misunderstanding here.

Your posted question asked about forcing a SaveAs.

I pointed out that if you have a cloned document - from a template - then you always will get a SaveAs. You can not DO just a Save. Any action on a cloned document - Close, Save, SaveAs will always get the same thing....A SaveAs.

Then you got into this useform.

"It doesn't look like the form is saved with the new document when opened by the .dot file"

I pointed out that userforms are never saved. You can always display a userform from a document, if that userform is in the template the document was cloned from. As long as that template is accessible.

Then you went into displaying the userform on opening the document.

1. Yes, if you want something to happen when a cloned document is opened, then that code must be in the Document_Open event of THAT cloned document.

Code in the template Document_Open will not fire. Why should it? The document itself (the template ITSELF) is not being opened.

However, you most certainly CAN display a userform from a template anytime you want. As stated, by calling it.

OK, so now - I think - you are putting the call to display the userform into the Document_New event...of the document.

Not the template. In other words - I think:

You have a template.
You make a document from that template.
That document - when you make a New document from it, NOT the template - will display the userform in the template.

Unless really required, generally this is a BAD use of Word. Why are you making a new document from a document? Instead of the template?

New documents should - generally - come from templates, not documents.

BTW: how are you even making a New document, from a document?

TrippyTom
01-10-2008, 03:55 PM
It's difficult for some people to state exactly what they're trying to convey sometimes. Your condescending remarks are difficult to wade through to get to the help you're trying to provide. I've been on this board for quite some time and frankly, I don't think I deserve that attitude.

First you said ALL macros are saved with the template, but you didn't specify forms were not saved and that's what I was trying to point out when I said, "It doesn't look like the form is saved with the new document when opened by the .dot file." Then you said forms are never saved and acted like I was stupid for not knowing that.

I am not creating a new document from a document. I had my code in the "Document_Open" routine instead of the "Document_New" routine. Not knowing that my code was in the wrong place, I thought it was not possible to do it in a template, which is why I started the thread in the first place to see if I could force a save-as.

You mentioned it was possible, but not how to do it by pointing out it had to go in the "Document_New" area of a template. Now, I realize nobody is a mind reader, but perhaps if you spent less time pointing out the flaws in my post, I would have understood earlier.

I appreciate the help and thank you for it; I just wanted to point out you are sounding quite stand-offish in many of your posts to new people (and some long-term members). I thought I would be used to it by now, but I'm not.

End result: I have my document as a template again calling the form from a "Document_New" routine and it works fine.

fumei
01-14-2008, 01:07 PM
My apologies....again.

I am glad it is working for you. And thanks for kicking my arrogant butt...again. Not you, but generally I mean...that my butt needs kicking now and then...oh...

Sorry to have put you off. Yes...my butt does need kicking now and then.