Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
A_Classic_Man A_Classic_Man is offline
external usenet poster
 
Posts: 5
Default Automatically Naming a document

I posted this on another group and did not get a response so I'll try
here.

I have a Word form with several fields one of which is a date field. I
would like the date entered in
the date field to show as the name of the form when the form is
emailed as
an attachment and/or saved. How is this accomplished?

Thanks in advance

Ron

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Automatically Naming a document

On Mon, 23 Jun 2008 16:05:11 -0700 (PDT), A_Classic_Man
wrote:

I posted this on another group and did not get a response so I'll try
here.

I have a Word form with several fields one of which is a date field. I
would like the date entered in
the date field to show as the name of the form when the form is
emailed as
an attachment and/or saved. How is this accomplished?

Thanks in advance

Ron


For the Save part, see
http://www.word.mvps.org/FAQs/Macros...efFilename.htm.

I don't know whether that will suffice for the email attachment or whether
you'll need a separate macro for that.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Automatically Naming a document

The big problem you are likely to encounter, whether you use a macro or the
method Jay pointed to is the question of reserved characters that are likely
to form part of the date. For example you would not be able to save a
document with the name 24/6/2008 - though 24 June 2008 would work. With this
proviso, assuming the field with the date is bookmarked Text1 - the
following macro run on entry to the next form field will initially save the
document with the name as the content of Text1

Sub Save_As_Date()
Dim oFld As FormFields
Dim sFname As String
Set oFld = ActiveDocument.FormFields
sFname = oFld("Text1").Result
MsgBox sFname
ActiveDocument.SaveAs sFname
End Sub

This will raise another issue relating to the use of macros at a remote
site, where you have no way of forcing the user to run macros contained in a
document. If you are going the whole hog and distributing a template then
you could add a button to send the document to you. The following macro uses
Outlook to send the document as attachment to the address entered having
saved the document with the required filename (subject to the same provisos
as above - plus the user has to be using Outlook)

Sub SendDocumentAsAttachment()
Dim bStarted As Boolean
Dim oFld As FormFields
Dim sFname As String
Set oFld = ActiveDocument.FormFields
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then 'Document has not been saved
'Save the document
sFname = oFld("Text1").Result
ActiveDocument.SaveAs sFname
End If
'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Open a new e-mail message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = " 'send to this address
.Subject = ActiveDocument.name 'This is the message subject
.Body = "See attached document" ' This is the message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
'**********************************
'If you want to view the message before it goes
'change the line above from .Send to .Display
'Otherwise the message is sent straight to the Outbox
'and if you have Outlook set to send mail immediately,
'it will simply be Sent
'with no obvious sign that Outlook has operated.
'Apart from the copy in the Outlook Sent folder
'**********************************
End With
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




A_Classic_Man wrote:
I posted this on another group and did not get a response so I'll try
here.

I have a Word form with several fields one of which is a date field. I
would like the date entered in
the date field to show as the name of the form when the form is
emailed as
an attachment and/or saved. How is this accomplished?

Thanks in advance

Ron



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
files organization and naming too many paths taken Microsoft Word Help 0 April 25th 08 07:10 PM
Document Naming Conventions for Standard Operating Procedures/Configuration Managment Invisible Man Microsoft Word Help 0 July 26th 06 10:56 PM
Automatically naming documents with data in form fields? AMG Microsoft Word Help 5 March 12th 06 09:03 PM
file naming DickV Microsoft Word Help 1 January 6th 06 02:08 PM
Naming a cell Candace Tables 4 June 24th 05 03:10 PM


All times are GMT +1. The time now is 02:56 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"