Create filename from form fields

3

3lliot

I want to enforce a file naming convention.

What I'd like to do is pop up a form when the user saves the file, which
prompts them for components for the filename, e.g their operational group, a
product abbreviation, version number etc. Maybe using drop-downs, so they can
select from a list.

Then the default filename is constructed from the form data.

Is this outrageously complex, or does anyone have any ideas for a simple
(ish) solution?

cheers
-Elliot
 
M

MLBeck

I do this a lot, but in my case I want the user to determine what
folder to save the file in. I load the form on Document_New.
I compose the strFileName from the various input box values in my
form. Then I run this SaveAsDialog and allow the user to determine the
location in which to save the file--which means the user could make
changes to the file name (which in my case is sometimes desirable). I
also use a function I got out of "VBA Developer's Handbook, 2nd
Edition" by Ken Getz and Mike Gilbert that lets you run the proposed
file name thru it and swap out unusable characters from the file name
(for example a backslash would get swapped out for a hyphen). But
since the book is copyrighted, I don't feel released to post that
function here.



Public Sub SaveAsDialog()

strFileName = txtFileName.value & "_" txtDate.value

With Dialogs(wdDialogFileSaveAs)
.Name = strFileName
.Show
End With
End Sub

I hope I wasn't saying the obvious, but it took me a while to figure
it out, so I thought I would pass on what has worked for me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top