Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-20-2013, 08:56 AM
john.adams john.adams is offline Document Filename Generator for Referencing Windows XP Document Filename Generator for Referencing Office 2010 32bit
Novice
Document Filename Generator for Referencing
 
Join Date: Mar 2013
Posts: 3
john.adams is on a distinguished road
Default Document Filename Generator for Referencing

Hi,

I work in an office that deals with a lot of client documents.

Is there a way or software to create or generate an automatic filename or reference number for each documents that are created so that it will automatically inserted at the footer.

For example, everytime i create a new document, a reference number will be automatically inserted in the footer. And this reference number will be used for database archiving.



I appreciate your help on this. This would greatly organize all my documents. Thanks
Reply With Quote
  #2  
Old 03-21-2013, 01:01 AM
macropod's Avatar
macropod macropod is offline Document Filename Generator for Referencing Windows 7 64bit Document Filename Generator for Referencing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi John,

If you insert a FILENAME field into the footer, that will reflect whatever the file's name is (you may need to do a Print Preview to get the field to update after saving with a new name). If the reference number is part of the filename, that will thus be included in the footer content.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-22-2013, 12:12 AM
eNGiNe eNGiNe is offline Document Filename Generator for Referencing Windows 7 32bit Document Filename Generator for Referencing Office 2010 64bit
Expert
 
Join Date: Jan 2012
Location: Brussels [BE]
Posts: 746
eNGiNe is on a distinguished road
Default

Similarly, you could generate random numbers in a spreadsheet – I do this for unique topic IDs – and use them in a document property field.
Reply With Quote
  #4  
Old 03-22-2013, 12:38 AM
macropod's Avatar
macropod macropod is offline Document Filename Generator for Referencing Windows 7 64bit Document Filename Generator for Referencing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi eNGiNe,

I'm not sure what generating random numbers in Excel would achieve. The same could be done via a Document_New macro (ie without involving Excel). The danger with either approach, though, is that you could end up with multiple files containing the same randomly-generated numbers. FWIW, I've also posted a number of macros in the Word vba forum for sequentially numbering documents (typically invoices).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-23-2013, 07:46 AM
john.adams john.adams is offline Document Filename Generator for Referencing Windows XP Document Filename Generator for Referencing Office 2010 32bit
Novice
Document Filename Generator for Referencing
 
Join Date: Mar 2013
Posts: 3
john.adams is on a distinguished road
Default

Hi, thank you for your replies. I am already aware of the filename field. This will work but this would not create automatic unique reference number for the document and filename it.

Is there a way where there is like a software where you can set the parameters for your filenaming rules. For example, i have a client, and i am going to prepare for him a specific document, let's say a contract. Can I automatically create a reference filename for this document for easy retrieval in the future?
Reply With Quote
  #6  
Old 03-23-2013, 01:55 PM
macropod's Avatar
macropod macropod is offline Document Filename Generator for Referencing Windows 7 64bit Document Filename Generator for Referencing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you add the following code and a Custom Document Property named "RefNum" to the file template's 'thisDocument' code module, every new file you create from the template will be allocated an incrementing number:
Code:
Sub Document_New()
Dim StrDefPath As String, StrTmpPath As String
Dim RefFile As String, RefNum As String, Rng As Range
'Indicate the default save path for files created from this template,
' including the final '\'.
StrTmpPath = "Filepath for documents based on this template"
StrDefPath = Options.DefaultFilePath(wdDocumentsPath)
Options.DefaultFilePath(wdDocumentsPath) = StrTmpPath
RefFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\RefNumber.txt"
If Dir(RefFile) = "" Then
  'If the Reference Number File file in the Word Workgroup folder, create it
  RefNum = 0
  Open RefFile For Output As #1
  Write #1, RefNum
  Close #1
End If
'Read the Reference Number File file in the Word Workgroup folder
Open RefFile For Input As #1
Input #1, RefNum
Close #1
' Increment the Reference Number
RefNum = RefNum + 1
DoEvents
'Update the Reference Number File file in the Word Workgroup folder
Open RefFile For Output As #1
Write #1, RefNum
Close #1
'Update the Reference Number in the document and prompt to save
With ActiveDocument
  .CustomDocumentProperties("RefNum") = RefNum
  Application.ScreenUpdating = False
  For Each Rng In ActiveDocument.StoryRanges
    Rng.Fields.Update
  Next
  Application.ScreenUpdating = True
  With .Dialogs(wdDialogFileSaveAs)
    .Name = StrTmpPath & RefNum
    .Show
  End With
End With
Options.DefaultFilePath(wdDocumentsPath) = StrDefPath
End Sub
 
Sub ResetReferenceNumber()
Dim RefFile As String, RefNum As String
'Re-set the Reference Number File file in the Word Workgroup folder
RefFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\RefNumber.txt"
Open RefFile For Input As #1
Input #1, RefNum
Close #1
RefNum = Trim(InputBox("What is the last valid Reference Number?" & vbCrLf & _
  "The current number is: " & RefNum))
If IsNumeric(RefNum) Then
  If CInt(RefNum) = RefNum Then
    Open RefFile For Output As #1
    Write #1, CInt(RefNum)
    Close #1
    Exit Sub
  End If
End If
MsgBox "Re-numbering error, please try again."
End Sub
The reference numbering is controlled by a text file stored in the workgroup templates folder, so that all members of the workgroup can use the same numbering sequence.

You could omit the Custom Document Property named "RefNum", but having it means the number remains with the document even if the filename is changed later on. If you want to give the file a default name that is more meaningful than just the reference number, you'll need to specify the rules for that.

The code also includes a StrTmpPath variable, for nominating the default save path for files created from the template.

I've also included some code to re-set the reference numbers.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 03-24-2013, 04:37 AM
john.adams john.adams is offline Document Filename Generator for Referencing Windows XP Document Filename Generator for Referencing Office 2010 32bit
Novice
Document Filename Generator for Referencing
 
Join Date: Mar 2013
Posts: 3
john.adams is on a distinguished road
Default

Thanks Paul,

However, i am really a novice in terms like these. I have no experience in creating these codes and i am not sure how to use them. Does this mean that i will still have to manually enter a filename for each document?

Is there a software or plug-in where it will create an automatic database or archive of all the documents created with the filename? For example, Contract A will be given a unique reference number or filename, like, Contract_101_John, where Contract= type of document, 101= reference number, and John=Client name.

I find it time consuming to manually filename the documents and this is also prone to error.

Thanks for your patience and continous help on this.
Reply With Quote
  #8  
Old 03-24-2013, 05:11 AM
macropod's Avatar
macropod macropod is offline Document Filename Generator for Referencing Windows 7 64bit Document Filename Generator for Referencing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For macro installation and usage instructions, see: http://www.gmayor.com/installing_macro.htm.
For instructions on adding custom document properties to a document/template, see: http://office.microsoft.com/en-us/wo...010047524.aspx

As indicated in my previous reply, the macro simply creates a sequential number and adds that to a custom document property. The macro then prompts the user to immediately save the document with that number. If you want anything fancier, you'll have to say exactly what the rules are for how a macro is supposed to work that out.

Depending on what you want to do with the file, with the above approach, you can use a FILENAME field and/or a DOCPROPERTY field in the header/footer to display the reference number in the document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 03-25-2013, 01:25 AM
eNGiNe eNGiNe is offline Document Filename Generator for Referencing Windows 7 32bit Document Filename Generator for Referencing Office 2010 64bit
Expert
 
Join Date: Jan 2012
Location: Brussels [BE]
Posts: 746
eNGiNe is on a distinguished road
Default

Well, using a spreadsheet instead of a macro means I can also maintain the spreadsheet as a record of which topic title uses which random number; and whenever I need to generate a new block of random numbers, I can sort the spreadsheet to weed out duplicates.
As m. Panhard observed, concerning an early gearbox: "it's rough and ready, but it works." <g>
Reply With Quote
  #10  
Old 03-25-2013, 01:42 AM
macropod's Avatar
macropod macropod is offline Document Filename Generator for Referencing Windows 7 64bit Document Filename Generator for Referencing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by eNGiNe View Post
Well, using a spreadsheet instead of a macro means I can also maintain the spreadsheet as a record of which topic title uses which random number; and whenever I need to generate a new block of random numbers, I can sort the spreadsheet to weed out duplicates.
Why do you suppose the numbers need to be random and how would you propose to get them into each new document? Manual transfer is unreliable and slow.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 03-26-2013, 12:14 AM
eNGiNe eNGiNe is offline Document Filename Generator for Referencing Windows 7 32bit Document Filename Generator for Referencing Office 2010 64bit
Expert
 
Join Date: Jan 2012
Location: Brussels [BE]
Posts: 746
eNGiNe is on a distinguished road
Default

In my case, as I said, I'm generating numbers for topic IDs; so I've decided to use random, and I also use a spreadsheet to put the tags I require round the numbers. Whether or not OP wants to use random numbers is entirely up to him, whether or not OP feels happy with copy/paste … also up to him. <g>
Reply With Quote
Reply

Tags
filename, msword, reference

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random number generator for Powerpoint 2011 kala85 PowerPoint 0 11-19-2011 06:16 AM
Document Filename Generator for Referencing Save Filename using Document Text Knawl Word 11 10-10-2011 03:00 AM
Document Filename Generator for Referencing Referencing text throughout a document design Word 1 01-10-2011 03:54 PM
Word: The document 'Filename' caused a serious error the last time ... martincruise Word 0 02-25-2010 01:47 AM
Document Generator HJJ Word 0 08-12-2009 03:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft