Help with automatic doc naming and correspondence ref numbering

S

Sharpe

Hi

I am new to VBA and have got this far with ideas and code from this forum,
thanks.
I ve started with a basic fax template and the code below works fine in
proposing a file name when the dialog box pops up etc. I have a ref field on
the fax that ref's the SaveDate or CreateDate and I can get this to reverse
and match my proposed file name.
My problem is depending how quick I fill in the fax I can end up with my
file name and the ref field being out by a minute. Another problem is that I
cant get the ref field (in a protected section) to update without printing it
first or right mousing it.
Any ideas on how I can get the ref or form fields and the reverse date
section of my file name to match always would be appreciated. (or is there an
easier way?)

Thanks

Sub FileSave()
Dim myFile As String

With ActiveDocument.FormFields
myFile = .Item("bmkProjectNo").Result
myFile = myFile & "-F" & Format(Now, "yyMMddHhNn")
myFile = myFile & Application.UserInitials
myFile = myFile & "-" & .Item("bmkSubject").Result
End With

With Dialogs(wdDialogFileSaveAs)
.Name = myFile
If .Display <> -1 Then
Exit Sub
End If
.Execute
End With

End Sub
 
S

Sharpe

All sorted thanks
For anyone else with similar problems
Sub FileSave()

Dim myFile As String

With ActiveDocument.FormFields
myFile = .Item("bmkProjectNo").Result
myFile = myFile & "-E" &
Format(ActiveDocument.BuiltInDocumentProperties("Creation Date"),
"yyMMddHhNn")
' myFile = myFile & "-E" & Format(Now, "yyMMddHhNn")
myFile = myFile & Application.UserInitials
myFile = myFile & "-" & .Item("bmkSubject").Result
End With

With Dialogs(wdDialogFileSaveAs)
.Name = myFile
If .Display <> -1 Then
Exit Sub
End If
.Execute
End With

End Sub
Sub FileSaveAs()

Dim myFile As String

With ActiveDocument.FormFields
myFile = .Item("bmkProjectNo").Result
myFile = myFile & "-E" &
Format(ActiveDocument.BuiltInDocumentProperties("Creation Date"),
"yyMMddHhNn")
' myFile = myFile & "-E" & Format(Now, "yyMMddHhNn")
myFile = myFile & Application.UserInitials
myFile = myFile & "-" & .Item("bmkSubject").Result
End With

With Dialogs(wdDialogFileSaveAs)
.Name = myFile
If .Display <> -1 Then
Exit Sub
End If
.Execute
End With

End Sub
 

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