PDA

View Full Version : Solved: Here's a challenging one to do with saving



sandam
02-10-2005, 10:26 AM
I posted earlier today on how to save within a macro and thankfully with help from DRJ that problem is a thing of the past.

My new conundrum is how to save the documents using the description prescribed by our office manual as well as adding a unique identifier in case of same descriptions given to documents?

I was thinking of using a time stamp but the PCs on the network are not completely sync-ed so that may create name conflicts on the documents drive.

Any ideas, suggestions etc would be greatly appreciated :)

Sub SaveTheDoc(sFileSaved As Boolean, Optional sChangename As Boolean = False)
Dim DocDescrip As String
If Not sFileSaved Or sChangename Then
'Docdescrip is the user created description of the document
DocDescrip = InputBox("Please enter a description of the document save as", "SAVING DOCUMENT")
While Len(DocDescrip) = 0
DocDescrip = InputBox("Please enter a description of the document save as", "SAVING DOCUMENT")
Wend
'i need to add a unique identifeier to the end of it but am not sure how
DocDescrip = docsPath + getDirectory(selectDirectory) + DocDescrip
ActiveDocument.SaveAs FileName:=DocDescrip
ActiveDocument.AttachedTemplate.Saved = True
Else
ActiveDocument.Save
End If
End Sub

Thanks in advance
Andrew;?

mdmackillop
02-10-2005, 01:17 PM
Hi Andrew,
I use the following in an automated routine to check for previous name and increment a suffix. Direct, SaveName and SaveAsName are my variables for the path and file
MD


With Application.FileSearch
.NewSearch
.LookIn = Direct
.SearchSubFolders = False
.FileName = SaveAsName
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
SaveAsName = SaveName & "-" & .FoundFiles.Count & ".doc"
End If
End With


In writing up for the KB, the foregoing code doid not work as required in 2003, and the following variation was used instead.


'Check for previous instances of the SaveName, if found add incremental suffix
With Application.FileSearch
.NewSearch
.LookIn = Direct
.SearchSubFolders = False
.FileName = SaveName & "*"
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
SaveAsName = SaveName & "-" & .FoundFiles.Count & ".doc"
End If
End With

sandam
02-11-2005, 02:26 AM
As a law firm documents carry similar nomenclature so i'll pitch this to my boss and se what he thinks (I think its cool), he's hinted at using a Global Unique ID (GUID) - do you have any experience in working with this?

sandam
02-11-2005, 03:41 AM
He liked it (no GUID thank goodness). Thanks for the help :)

Andrew;?

mdmackillop
02-11-2005, 06:32 AM
The only familiarity I have with it is the good old Scottish phrase
Nae bloody guid!

I've put my mailmerge and autofiling routine, which may be of interest, as a KB entry, which hopefully will be approved shortly

sandam
02-11-2005, 09:58 AM
cool. i'm sure it will.

Thanks again for the help, my biggest failing with macro writing is knowing what I want to do and convincing VBA to act like VB .net to do it instead of working with Word :)