Re: Automatic File Saving
- From: "Graham Mayor" <gmayor@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Jan 2009 09:31:53 +0200
With UserSaveDialog
.name = "D:\Jon\NDA - " & TextBox1.Text
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
JB wrote:
Hi Graham,
I'm afraid i'm only a beginner at this programming lark so most of the
things i do are cobbled together from various sources and i'd be the
first to admit that i don't always fully understand how they work.
So far i've got the code below:-
Private Sub CommandButton1_Click()
With ActiveDocument
.Bookmarks("company_name").Range _
.InsertBefore TextBox1
.Bookmarks("company_name2").Range _
.InsertBefore TextBox1
.Bookmarks("company_name3").Range _
.InsertBefore TextBox1
.Bookmarks("address").Range _
.InsertBefore TextBox2
End With
UserForm1.Hide
Dim UserSaveDialog As Dialog
Set UserSaveDialog = Dialogs(wdDialogFileSaveAs)
If ActiveDocument.Path <> "" Then
ActiveDocument.Save
Exit Sub
End If
With UserSaveDialog
.Name = "D:\Jon\NDA - ???"
If .Display Then
If LCase$(Left$(CurDir, 6)) <> "D:\Jon" Then
MsgBox "Documents can't be saved in that folder. Please try
again."
Exit Sub
End If
UserSaveDialog.Execute
End If
End With
End Sub
It does 90% of what i want. I would just like it to add what's in the
company_name property onto the end of the filename where the ???
currently are. I guess it would also be nice if it just saved it
rather than going to the save as dialog box.
Duplicate files names shouldn't be a problem as we'll only ever have
one with each company.
Thanks,
Jon
"Graham Mayor" wrote:
The short answer is yes of course. You can use the information from
the userform to create the filename, and 'saveas' with that
filename. However, what is the relevance of NDA? 'Non Disclosure
Agreement? How do you want to handle potentially duplicated
filenames?
See for example
http://www.gmayor.com/automatic_numbering_documents.htm .
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
JB wrote:
I currently have a word template that i have set up with a userform
into which two pieces of information are entered, "company name" and
"address". On closing the userform it runs a save as function and
goes to the correct folder. All the user has to do is enter the
filename and click save.
Now the filename will always be in the form 'NDA - "company name"'.
My question is, is there any way i can set this up so that it saves
the file automatically with the correct filename when the userform
is closed?
Thanks,
Jon
.
- References:
- Automatic File Saving
- From: JB
- Re: Automatic File Saving
- From: Graham Mayor
- Re: Automatic File Saving
- From: JB
- Automatic File Saving
- Prev by Date: Re: How can I add automatic comments with date and time?
- Next by Date: RE: WORD + ACCESS vb
- Previous by thread: Re: Automatic File Saving
- Next by thread: Reset font/character formatting while preserving character style text
- Index(es):