PDA

View Full Version : Solved: Save As



Kindly_Kaela
12-13-2006, 11:01 AM
First off, HI EVERYONE, I'm new to this site :cloud9:

I'm trying to create a Proposal Developing VBA program with Word 2003. So far, my template opens, change are made based on the users check boxes. Here's where I'm stuck....

What code do I use to show the user a SaveAs window, let them name it, and save the changed template as a .doc?

Thank you!
Kaela

mdmackillop
12-13-2006, 11:16 AM
Hi Kaela,
Welcome to VBAX
It's certainly not normal usage to allow users to change a template in this manner.
Here's a sample template which will open a new document based on the template, and display a simple userform. The button on the form will show the SaveAs dialog. The Code is in ThisDocument module of the template and the UserForm itself.
Regards
MD

Kindly_Kaela
12-13-2006, 11:57 AM
Hi MD,

I must have explained it wrong. You're right, I don't want users to rename or change my template file. The template file is Read-Only.

I want a SaveAs dialog to appear, and the user saves the changes as a .doc where ever they want. My created template would stay the same. So essentially this would creaete a 2nd file....one that is no longer read-only and saved on the user's PC as a .doc instead of .dot

Hope that makes sense...please advise.

lucas
12-13-2006, 12:04 PM
When they try to close the file created from the template they will be prompted for a file name and location by default...

Edit: and it will be saved as a .doc not .dot

mdmackillop
12-13-2006, 12:08 PM
As long your users use File New, double click an icon or use a shortcut to open the templare, a new document will be created automatically.

fumei
12-13-2006, 12:26 PM
I am trying to understand what the problem is. As both Steve and Malcolm have mentioned, if the document is cloned properly from a template (using File > New and selecting the template), then the user clicking Save OR SaveAs will get the SaveAs dialog.

There IS no Save for a cloned new document. There is only SaveAs.

So....please clarify what it is you are asking about. Are you asking how to actually display the dialog, without the user clicking anything?

Are you asking how to display it with some sort of preset name?

Kindly_Kaela
12-13-2006, 12:41 PM
I fixed it, maybe this code will clarify what it is I was trying to do.

Sub ShowSaveAsDialog()
Dim dlgSaveAs As FileDialog
Set dlgSaveAs = Application.FileDialog( _
FileDialogType:=msoFileDialogSaveAs)
dlgSaveAs.Show
dlgSaveAs.Execute
End Sub

Basically, the user types in information, the template populates with that information. Before the VBA is done running, it asks the user to save it.

Thanks everyone!

fumei
12-14-2006, 10:46 AM
Glad it works for you.

I have a question though.

What fires Sub ShowSaveAsDialog()?

And it still seems to miss the point. There IS only a SaveAs with a document from a template.

A new document is created from a template. Stuff is done...whatever...it doesn't matter what. As long as a single character is put in that document, the following happens.

1. The user tries to close the document. They get asked to save the file. If yes, they get File SaveAs dialog.

2. The user tries to Save the document. They get the SaveAs dialog.

3. The user tries to SaveAs the document. They get the SaveAs dialog.

However, it seems that you wanted to have the SaveAs dialog display without the user clicking anything. Which - I believe - is the answer to my question.

"Are you asking how to actually display the dialog, without the user clicking anything?"

Kindly_Kaela
12-14-2006, 12:28 PM
Yea Gerry, exactly! You're also right, it's not necessary.

mdmackillop
12-17-2006, 07:17 AM
Hi Kaela,
If this is now solved, can you mark it so using Thread Tools
Regards
MD